示例#1
0
        public DudeBase()
        {
            Shadow = new img("assets/NatureBoy/alpha/2.png");
            Shadow.style.position = IStyle.PositionEnum.absolute;

            SelectionImage = new img("assets/NatureBoy/alpha/green-ring.png");
            SelectionImage.style.position = IStyle.PositionEnum.absolute;

            HotImage = new img("assets/NatureBoy/alpha/yellow-ring-50.png");
            HotImage.style.position = IStyle.PositionEnum.absolute;


            Control.style.position = IStyle.PositionEnum.absolute;
            Control.style.overflow = IStyle.OverflowEnum.hidden;

            this.IsSelected = false;

            Control.appendChild(Shadow, SelectionImage, HotImage);

            Control.onmouseover +=
                delegate
            {
                this.IsHot = true;
            };

            Control.onmouseout +=
                delegate
            {
                this.IsHot = false;
            };

            this.HotImage.style.display = IStyle.DisplayEnum.none;
        }
示例#2
0
        public void UpdateFrameImage(FrameInfo frame)
        {
            var e = frame.Image;

            var ix = System.Convert.ToInt32(e.width * this.Zoom.Value);
            var iy = System.Convert.ToInt32(e.height * this.Zoom.Value);

            var dx = System.Convert.ToInt32((Width - e.width - frame.OffsetX) * this.Zoom.Value);
            var dy = System.Convert.ToInt32((Height - e.height - frame.OffsetY) * this.Zoom.Value);

            var a64 = (this.Zoom.Value * 64).ToInt32();
            var a32 = a64 / 2;
            var a16 = a32 / 2;

            this.CurrentFrameBufferImage.src = e.src;
            this.CurrentFrameBufferImage.style.SetLocation(
                dx / 2,
                dy - a16,
                ix,
                iy
                );

            this.CurrentFrameImage.style.display       = IStyle.DisplayEnum.none;
            this.CurrentFrameBufferImage.style.display = IStyle.DisplayEnum.block;

            var f = this.CurrentFrameImage;

            this.CurrentFrameImage       = this.CurrentFrameBufferImage;
            this.CurrentFrameBufferImage = f;
        }
示例#3
0
        public DudeBase()
        {
            Shadow = new img("assets/NatureBoy/alpha/2.png");
            Shadow.style.position = IStyle.PositionEnum.absolute;

            SelectionImage = new img("assets/NatureBoy/alpha/green-ring.png");
            SelectionImage.style.position = IStyle.PositionEnum.absolute;

            HotImage = new img("assets/NatureBoy/alpha/yellow-ring-50.png");
            HotImage.style.position = IStyle.PositionEnum.absolute;


            Control.style.position = IStyle.PositionEnum.absolute;
            Control.style.overflow = IStyle.OverflowEnum.hidden;

            this.IsSelected = false;

            Control.appendChild(Shadow, SelectionImage, HotImage);

            Control.onmouseover +=
                delegate
                {
                    this.IsHot = true;
                };

            Control.onmouseout +=
                delegate
                {
                    this.IsHot = false;
                };

            this.HotImage.style.display = IStyle.DisplayEnum.none;
        }
示例#4
0
        public static void Interval()
        {
            int topThreshold = 110;
            int botThreshold = 855;

            img bitmapClass = new img(topThreshold, botThreshold);

            bitmapClass.screenshot();
            using (Bitmap bmp = new Bitmap("screen.bmp"))
            {
                var scanning = bitmapClass.scanning(bmp);
                if (counter == 0)
                {
                    previous = scanning;
                    Console.WriteLine("First Initate initial state :{0}", previous);
                }
                else
                {
                    if (scanning == "B" && previous != "B")
                    {
                        Console.WriteLine("Statechange from {0} to {1} BUY Signal", previous, scanning);
                        Connect con = new Connect(1);
                        previous = scanning;
                    }
                    else if (scanning == "S" && previous != "S")
                    {
                        Console.WriteLine("Statechange from {0} to {1} SELL signal", previous, scanning);
                        Connect con = new Connect(2);
                        previous = scanning;
                    }
                }
            }
            counter++;
        }
示例#5
0
        public DudeBase()
        {
            Shadow = new _2();
            Shadow.style.position = IStyle.PositionEnum.absolute;

            SelectionImage = new green_ring();
            SelectionImage.style.position = IStyle.PositionEnum.absolute;

            HotImage = new  yellow_ring_50();
            HotImage.style.position = IStyle.PositionEnum.absolute;


            Control.style.position = IStyle.PositionEnum.absolute;
            Control.style.overflow = IStyle.OverflowEnum.hidden;

            this.IsSelected = false;

            Control.appendChild(Shadow, SelectionImage, HotImage);

            Control.onmouseover +=
                delegate
                {
                    this.IsHot = true;
                };

            Control.onmouseout +=
                delegate
                {
                    this.IsHot = false;
                };

            this.HotImage.style.display = IStyle.DisplayEnum.none;
        }
示例#6
0
        public Dude2()
        {
            this.CurrentFrameImage       = new img();
            this.CurrentFrameBufferImage = new img();

            this.Control.style.overflow = IStyle.OverflowEnum.visible;

            this.CurrentFrameImage.style.display       = IStyle.DisplayEnum.none;
            this.CurrentFrameBufferImage.style.display = IStyle.DisplayEnum.none;

            this.Control.appendChild(this.CurrentFrameImage, this.CurrentFrameBufferImage);

            /*
             * this.CurrentFrameImage.style.border = "1px solid blue";
             * this.CurrentFrameBufferImage.style.border = "1px solid blue";
             * this.Control.style.border = "1px solid yellow";
             * this.Shadow.style.border = "1px solid red";
             */
            this.Zoom.Changed +=
                delegate
            {
                UpdateFrameImage();
                // UpdateSize();
                TeleportTo(this.X, this.Y);
            };
        }
示例#7
0
        public string GetSample(string username, string repo, string branch, string dir)
        {
            var url = GetUrl(username, repo, branch, dir);

            return(@$ "<img src='{url}'/>

``` HTML
<img src='{url}'/>
示例#8
0
 private void imglist_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (imglist.SelectedIndex == -1)
     {
         return;
     }
     selectmap = ((img)imglist.SelectedItem).map;
     selectimg = (img)imglist.SelectedItem;
     updateDisplay();
 }
示例#9
0
        public Dude()
        {
            Idle = new img("assets/NatureBoy/dude1/1.png")
            {
                className = "idle"
            };
            Idle.style.position = IStyle.PositionEnum.absolute;


            Walk1 = new img("assets/NatureBoy/dude1/3.png")
            {
                className = "walk1"
            };
            Walk1.style.position = IStyle.PositionEnum.absolute;

            Walk2 = new img("assets/NatureBoy/dude1/4.png")
            {
                className = "walk2"
            };
            Walk2.style.position = IStyle.PositionEnum.absolute;

            SetClipping(2, 1);
            IsWalking = false;
            Zoom      = 1;


            Control.appendChild(Idle, Walk1, Walk2);

            this.Walk +=
                delegate
            {
                if (this.TargetLocation == null)
                {
                    return;
                }

                var z = this.TargetLocation.GetRange(this.CurrentLocation);

                if (z / this.CurrentSpeed < 1)
                {
                    // we are there
                    this.IsWalking = false;

                    if (this.DoneWalking != null)
                    {
                        this.DoneWalking(this);
                    }

                    return;
                }

                this.TeleportToArc(this.CurrentSpeed, this.Rotation);
            };
        }
        public IHttpActionResult PostImage(img i)
        {
            byte[]     b = Convert.FromBase64String(i.i);
            tblProduct p = new tblProduct
            {
                ProductImg = b
            };

            db.tblProducts.Add(p);
            db.SaveChanges();
            return(Json(b));
        }
示例#11
0
        public Dude()
        {



            Idle = new img("assets/NatureBoy/dude1/1.png") { className = "idle" };
            Idle.style.position = IStyle.PositionEnum.absolute;


            Walk1 = new img("assets/NatureBoy/dude1/3.png") { className = "walk1" };
            Walk1.style.position = IStyle.PositionEnum.absolute;

            Walk2 = new img("assets/NatureBoy/dude1/4.png") { className = "walk2" };
            Walk2.style.position = IStyle.PositionEnum.absolute;

            SetClipping(2, 1);
            IsWalking = false;
            Zoom = 1;


            Control.appendChild(Idle, Walk1, Walk2);

            this.Walk +=
                delegate
                {
                    if (this.TargetLocation == null)
                        return;

                    var z = this.TargetLocation.GetRange(this.CurrentLocation);

                    if (z / this.CurrentSpeed < 1)
                    {
                        // we are there
                        this.IsWalking = false;

                        if (this.DoneWalking != null)
                            this.DoneWalking(this);

                        return;
                    }

                    this.TeleportToArc(this.CurrentSpeed, this.Rotation);
                };




        }
示例#12
0
        public JsonResult UpdateUserProfile(UserProfileModel up, img imagpath)
        {
            var res = "";

            try
            {
                //if (up.ImgPath != "" && up.ImgPath != null)
                //{
                //    if (up.ImgPath.IndexOf(".png") > -1) { }
                //    else
                //    {
                //        Base64ToImage(up.ImgPath).Save(Server.MapPath("~/ProfilePics/" + up.UserID + ".png"));
                //        up.ImgPath = "/ProfilePics/" + up.UserID + ".png";
                //    }
                //}
                //else
                //{
                //    up.ImgPath = "http://mps.manpowersupplier.net/img/admin.png";
                //}
                if (imagpath.ImgPath != "" && imagpath.ImgPath != null)
                {
                    if (imagpath.ImgPath.IndexOf(".png") > -1)
                    {
                    }
                    else
                    {
                        Base64ToImage(imagpath.ImgPath).Save(Server.MapPath("~/ProfilePics/" + up.UserID + ".png"));
                        imagpath.ImgPath = "/ProfilePics/" + up.UserID + ".png";
                    }
                }
                else
                {
                    imagpath.ImgPath = "http://mps.manpowersupplier.net/img/admin.png";
                }
                up.ImgPath = imagpath.ImgPath;
                string jsr = ur.UpdateUserProfile(up);
                return(Json((new JavaScriptSerializer()).DeserializeObject(jsr), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorWriter.WriteLog(ex.GetType().ToString(), ex.GetType().Name.ToString(), ex.InnerException.ToString(), "UpdateUserProfile", "UserDashboardController");
                res = ex.Message.ToString();
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult upload(ImageViewModel model)
        {
            tutorEntities et    = new tutorEntities();
            int           imgId = 0;
            var           file  = model.ImageFile;

            byte[] imagebyte = null;
            if (file != null)
            {
                file.SaveAs(Server.MapPath("/savedimages/" + file.FileName));
                BinaryReader reader = new BinaryReader(file.InputStream);
                imagebyte = reader.ReadBytes(file.ContentLength);
                img img = new img();
                img.Title   = file.FileName;
                img.imgByte = imagebyte;
                img.Path    = "/savedimages/" + file.FileName;
                et.imgs.Add(img);
                et.SaveChanges();
                imgId = img.imgId;
            }

            return(Json(imgId, JsonRequestBehavior.AllowGet));
        }
示例#14
0
        private (string, string) GetSubjectAndText(MessageType type, Guid unsbsciberId, string name)
        {
            switch (type)
            {
            case MessageType.SharePrompt:
                return("", "");

            case MessageType.Version2Info:
            case MessageType.Version3Info:
                return("New version of Backgammon", @$ "<p>Hi {name}!</p>
<img src='https://backgammon.azurewebsites.net/assets/images/banner.jpg'>
<p>You have a new Backgammon message.</p>
<p><a href='https://backgammon.azurewebsites.net/messages'>Go there and read the news.<a/></p>
<p><a href='https://backgammon.azurewebsites.net/api/message/unsubscribe?id={unsbsciberId}'>Unsubscribe from all email notifications.</a></p>
<p>
    Kind Regards<br/>
    /Kristian
</p>
");

            default:
                throw new NotImplementedException();
            }
        }
示例#15
0
        static async Task RequestBeat(DateTime time)
        {
            if (time > CheckTime)
            {
                //Abbybot.print("running abc!!");
                CheckTime = CheckTime.AddMinutes(1);
                SocketTextChannel channel    = null;
                List <Character>  characters = await AbbyBooruCharacterSql.GetListFromSqlAsync();

                foreach (var character in characters)
                {
                    //Abbybot.print("{}");
                    //AbbybotGuild
                    bool          safe = true;
                    List <string> tags = new List <string>();
                    try
                    {
                        var Gl = Apis.Discord.__client.Guilds.ToList().Any(x => x.Id == character.guildId);

                        if (!Gl)
                        {
                            continue;
                        }
                        //Console.WriteLine($"{character.tag}, guild found!");
                        var G = Apis.Discord.__client.GetGuild(character.guildId);

                        var pref = await GuildSql.GetGuild(character.guildId);

                        if (pref.PrefAbbybot != Apis.Discord.__client.CurrentUser.Id)
                        {
                            continue;
                        }
                        channel = G.GetTextChannel(character.channelId);

                        tags.Add(character.tag);
                        //Console.WriteLine($"channel nsfw? {channel.IsNsfw}, character lewd? {character.IsLewd}");
                        safe = !channel.IsNsfw;
                    }
                    catch (Exception e)
                    {
                        //Console.WriteLine(e.ToString());
                        continue;
                    }
                    if (safe)
                    {
                        tags.Add("rating:safe");
                    }


                    Post[] charpicx = new Post[0];
                    try
                    {
                        charpicx = (await Apis.AbbyBooru.GetLatest(tags.ToArray())).ToArray();
                        if (charpicx == null)
                        {
                            continue;
                        }
                        if (charpicx.Length > 5)
                        {
                            charpicx = charpicx.Take(5).ToArray();
                        }
                        else
                        {
                            continue;
                        }
                    } catch {
                        //Console.WriteLine("aaaa");
                    }
                    List <img> nngs    = new List <img>();
                    var        postIds = (await AbbyBooruCharacterSql.GetLatestPostIdsAsync(character));

                    Post[] eeee = charpicx.Where(x => !postIds.Contains((ulong)x.id)).Take(5).ToArray();

                    foreach (var ex in eeee)
                    {
                        img nng = new img()
                        {
                            Id     = (ulong)ex.id,
                            imgurl = ex.fileUrl,
                            source = ex.source,
                            safe   = (ex.rating.Contains($"safe")),
                            GelId  = ex.id,
                            md5    = ex.md5
                        };
                        nngs.Add(nng);
                    }

                    for (int i = 0; i < nngs.Count; i++)
                    {
                        img sr = nngs[i];

                        EmbedBuilder embededodizer = new EmbedBuilder
                        {
                            ImageUrl = sr.imgurl
                        };

                        string fixedsource = "no source found";
                        try
                        {
                            if (sr.source != null)
                            {
                                fixedsource = sr.source.Replace("/member_illust.php?mode=medium&amp;illust_id=", "/en/artworks/");
                            }

                            embededodizer.AddField($"New picture of {character.tag.Replace("_", " ")} :)", $"[Source]({fixedsource})");
                            embededodizer.Color = Color.LightOrange;

                            await channel.SendMessageAsync("", false, embededodizer.Build());
                        }
                        catch { }

                        await AbbyBooruCharacterSql.AddLatestPostIdAsync(character.Id, sr.Id, sr.GelId);

                        if (character.Id == 3)
                        {
                            var dl = await FunAbbybotFactsSql.GetFactsList(true, "twitter");

                            Random r      = new Random();
                            var    ranfac = dl.Count > 0? dl[r.Next(0, dl.Count)].fact:"";

                            Tweet tweet = new()
                            {
                                message   = $"A new tweet just came in from gelbooru!!\n{ranfac}",
                                url       = sr.imgurl,
                                sourceurl = fixedsource,
                                GelId     = sr.GelId
                            };

                            await TweetQueueSql.Add(tweet, true);
                        }
                    }
                }
            }
        }
    }
示例#16
0
        public void UpdateFrameImage(FrameInfo frame)
        {

            var e = frame.Image;

            var ix = System.Convert.ToInt32(e.width * this.Zoom.Value);
            var iy = System.Convert.ToInt32(e.height * this.Zoom.Value);

            var dx = System.Convert.ToInt32((Width - e.width - frame.OffsetX) * this.Zoom.Value);
            var dy = System.Convert.ToInt32((Height - e.height - frame.OffsetY) * this.Zoom.Value);

            var a64 = (this.Zoom.Value * 64).ToInt32();
            var a32 = a64 / 2;
            var a16 = a32 / 2;

            this.CurrentFrameBufferImage.src = e.src;
            this.CurrentFrameBufferImage.style.SetLocation(
                dx / 2,
                dy - a16,
                ix,
                iy
                );

            this.CurrentFrameImage.style.display = IStyle.DisplayEnum.none;
            this.CurrentFrameBufferImage.style.display = IStyle.DisplayEnum.block;

            var f = this.CurrentFrameImage;

            this.CurrentFrameImage = this.CurrentFrameBufferImage;
            this.CurrentFrameBufferImage = f;

        }
示例#17
0
        public Dude2()
        {
            this.CurrentFrameImage = new img();
            this.CurrentFrameBufferImage = new img();

            this.Control.style.overflow = IStyle.OverflowEnum.visible;

            this.CurrentFrameImage.style.display = IStyle.DisplayEnum.none;
            this.CurrentFrameBufferImage.style.display = IStyle.DisplayEnum.none;

            this.Control.appendChild(this.CurrentFrameImage, this.CurrentFrameBufferImage);

            /*
            this.CurrentFrameImage.style.border = "1px solid blue";
            this.CurrentFrameBufferImage.style.border = "1px solid blue";
            this.Control.style.border = "1px solid yellow";
            this.Shadow.style.border = "1px solid red";
            */
            this.Zoom.Changed +=
                delegate
                {
                    UpdateFrameImage();
                    // UpdateSize();
                    TeleportTo(this.X, this.Y);

                };
        }
示例#18
0
    IEnumerator UploadTexture(string GetTex, int typeimg)
    {
        EncryptDecipherTool.UserMd5();
        //MessageManager._Instantiate.Show("上传开始");
        string  url  = Static.Instance.URL + "ajax_fenxiang_put.php"; /*Static.Instance.URL + "upimage";*/
        WWWForm form = new WWWForm();
        img     data = new img();

        data.imgData = GetTex;
        Debug.Log(GetTex);
        Debug.Log(url);
        form.AddField("huiyuan_id", Static.Instance.GetValue("huiyuan_id"));
        form.AddField("time", Static.Instance.GetValue("time"));
        form.AddField("token", Static.Instance.GetValue("token"));
        form.AddField("img_url", GetTex);
        //Debug.Log(Static.Instance.GetValue("huiyuan_id"));
        //Debug.Log(Static.Instance.GetValue("time"));
        //Debug.Log(Static.Instance.GetValue("token"));
        //MessageManager._Instantiate.AddLockNub();
        WWW www = new WWW(url, form);

        yield return(www);

        MSG.text = string.Empty;
        //MessageManager._Instantiate.DisLockNub();
        if (www.error != null)
        {
            MSG.text = www.error;
            //MessageManager._Instantiate.Show("图片上传失败");
        }
        else
        {
            Debug.Log(www.text + "++++++++");
            MSG.text = www.text;
            Debug.Log(www.text);
            //MessageManager._Instantiate.Show("图片上传成功");

            string jsondata = System.Text.Encoding.UTF8.GetString(www.bytes, 3, www.bytes.Length - 3);
            jsondata = jsondata.Remove(0, 0);
            //CreateFile(Application.streamingAssetsPath, "json.txt", jsondata);
            Static.Instance.DeleteFile(Application.persistentDataPath, "json.txt");
            Static.Instance.CreateFile(Application.persistentDataPath, "json.txt", jsondata);
            ArrayList infoall = Static.Instance.LoadFile(Application.persistentDataPath, "json.txt");
            String    sr      = null;
            foreach (string str in infoall)
            {
                sr += str;
            }
            JsonData jd = JsonMapper.ToObject(sr);
            tiptxt.text = jd["msg"].ToString();



            if (typeimg == 0)
            {
            }
            else
            {
            }
        }
    }
示例#19
0
        public static List <img> createMissingImageList(string[] errorText)
        {
            List <img> icsList = new List <img>();

            string[] elements = new string[0];
            string   temp;
            string   imageName;


            // If we weren't passed an arg, load the log file
            if (errorText == null)
            {
                string        curr;
                List <string> storage = new List <string>();
                using (StreamReader s = new StreamReader(Environment.CurrentDirectory.ToString() + @"\Logs\ics.log")) {
                    while ((curr = s.ReadLine()) != null)
                    {
                        storage.Add(curr.Substring(4));
                    }
                }
                errorText = storage.ToArray();
            }


            foreach (string s in errorText)
            {
                img curr = new img();
                elements = s.Split(',');
                // constraints
                if (elements[0].Length <= 0)
                {
                    break;
                }
                if (elements[1].Contains("catalog.jsp"))
                {
                    continue;
                }
                try {
                    imageName = elements[0].Trim().Substring(elements[0].Trim().LastIndexOf('/') + 1, elements[0].Trim().IndexOf('?') - elements[0].Trim().LastIndexOf('/') - 1);
                    temp      = elements[0].Trim().Substring(elements[0].Trim().LastIndexOf("wid=") + 4, elements[0].Trim().Substring(elements[0].Trim().LastIndexOf("wid=")).IndexOf("&") - 4);
                    imageName = imageName.Replace("_sw", "");
                    // Product Id
                    string productId;
                    if (elements[1].Contains("product"))
                    {
                        productId = elements[1].Substring(elements[1].IndexOf("product/prd-") + 12);
                        productId = productId.Substring(0, productId.IndexOf("/"));
                    }
                    else
                    {
                        productId = "";
                    }
                    curr.productId = productId;
                    // Color
                    curr.color = imageName.Substring(imageName.IndexOf("_") + 1);
                    // Type
                    if (temp.Equals("30"))
                    {
                        curr.type = "Swatch";
                    }
                    else if (temp.Equals("1000"))
                    {
                        curr.type = "Zoom";
                    }
                    else if (temp.Equals("350"))
                    {
                        curr.type = "Main";
                    }
                    else if (temp.Equals("50"))
                    {
                        curr.type = "Carousel";
                    }
                    else if (temp.Equals("20"))
                    {
                        curr.type = "Swatch-Col";
                    }
                    else
                    {
                        curr.type = "Other";
                    }
                    // nav_from
                    curr.nav_from = elements[1];

                    // imageName
                    curr.imageName = imageName;
                } catch (Exception ex) {
                    logger.Error("PARSING ERROR - " + ex.Message);
                }
                icsList.Add(curr);
            }
            // write csv
            if (File.Exists(Environment.CurrentDirectory + @"\out\MissingImages.csv"))
            {
                File.Delete(Environment.CurrentDirectory + @"\out\MissingImages.csv");
            }
            File.Create(Environment.CurrentDirectory + @"\out\MissingImages.csv").Close();

            using (StreamWriter sw = new StreamWriter(Environment.CurrentDirectory + @"\out\MissingImages.csv")) {
                for (int i = 0; i < icsList.Count; i++)
                {
                    sw.WriteLine(String.Format("NULL,{0},{1},{2},{3},{4}", ((img)icsList[i]).productId, ((img)icsList[i]).type, ((img)icsList[i]).color, ((img)icsList[i]).imageName, ((img)icsList[i]).nav_from));
                }
            }
            return(icsList);
        }
示例#20
0
                public async Task <HttpResponseMessage>  PostUserImage()   
                
        {
              
                        Dictionary <string,  object>  dict  =  new Dictionary <string,  object>();   

                        try  
                         {
                  
                  
                                    var httpRequest  =  HttpContext.Current.Request;   

                  
                                foreach (string file in httpRequest.Files)   
                                
                {
                      
                                            HttpResponseMessage response  =  Request.CreateResponse(HttpStatusCode.Created);   
                      
                                            var postedFile  =  httpRequest.Files[file];   

                                        if (postedFile  !=  null  &&  postedFile.ContentLength  >  0)   
                                        
                    {
                          
                          
                                                    int MaxContentLength  =  1024  *  1024  *  1;  //Size = 1 MB  
                          
                                                IList <string>  AllowedFileExtensions  =  new List <string>   {
                              ".jpg",   ".gif",   ".png"  
                        };   

                                                    var ext  =  postedFile.FileName.Substring(postedFile.FileName.LastIndexOf('.'));   
                                                    var extension  =  ext.ToLower();   
                                                if (!AllowedFileExtensions.Contains(extension))   
                                                
                        {
                              
                              
                                                            var message  =  string.Format("Please Upload image of type .jpg,.gif,.png.");   
                              
                                                        dict.Add("error",  message);   

                                                        return Request.CreateResponse(HttpStatusCode.BadRequest,  dict);   
                                                        
                        }

                          
                                                else if (postedFile.ContentLength  >  MaxContentLength)   
                                                
                        {
                              
                              
                                                            var message  =  string.Format("Please Upload a file upto 1 mb.");   
                              
                                                        dict.Add("error",  message);   

                                                        return Request.CreateResponse(HttpStatusCode.BadRequest,  dict);   
                                                        
                        }

                          
                                                else  
                                                 {
                            img           bn = new img();
                            tutorEntities db = new tutorEntities();

                                                        var filePath  =  HttpContext.Current.Server.MapPath("~/Userimage/"   +  postedFile.FileName  +  extension);


                            bn.Path  = filePath;
                            bn.Title = postedFile.FileName;
                                                        postedFile.SaveAs(filePath);   
                              
                            db.imgs.Add(bn);

                            db.SaveChanges();
                                                    
                        }   
                                                
                    }

                      
                      
                                                var message1  =  string.Format("Image Updated Successfully.");   

                                        return Request.CreateErrorResponse(HttpStatusCode.Created,  message1);  ;   
                                        
                }

                  
                                        var res  =  string.Format("Please Upload a image.");   
                                dict.Add("error",  res);   
                                return Request.CreateResponse(HttpStatusCode.NotFound,  dict);   
                                
            }   
                        catch (Exception ex)   
                        
            {
                  
                                    var res  =  string.Format("some Message");   

                                dict.Add("error",  res);   
                                return Request.CreateResponse(HttpStatusCode.NotFound,  dict);   
                                
            }

              
                            
        }
示例#21
0
        public static void addDepartmentNumbers(List <img> icsList)
        {
            // hurr durr pointer
            List <img> icsListBackup        = new List <img>(icsList.ToArray());
            int        count                = 0;
            Dictionary <string, string> map = new Dictionary <string, string>();

            // init database
            con = new OracleConnection();
            con.ConnectionString =
                "Data Source=" +
                "(DESCRIPTION = " +
                "(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.4)(PORT = 9101))" +
                "(CONNECT_DATA =" +
                "(SID = KOHLDBPA1)" +
                ")" +
                ");Persist Security Info=True;User ID=pkmdes2;Password=pkd2iu4ro";
            // build the query
            string prodIds = "";
            string collIds = "";

            // chunk in 500s
            while (icsList.Count > 0)
            {
                prodIds = "";
                for (int i = 0; i <= 500; i++)
                {
                    if (icsList.Count != 0)
                    {
                        img curr = icsList[0];
                        //foreach (img curr in icsList) {
                        // might as well count here
                        count++;
                        if (!curr.productId.Contains("c"))
                        {
                            prodIds += "'" + curr.productId + "'" + ", ";
                        }
                        else
                        {
                            collIds += "'" + curr.productId + "'" + ", ";
                        }
                        icsList.Remove(curr);
                    }
                }

                // fix leading comma
                prodIds = prodIds.Substring(0, prodIds.Length - 2);
                // Generate sql
                string sql = "SELECT product_id, max(dept_no) from atgprdcata.kls_sku sku";
                sql += " inner join atgprdcata.dcs_prd_chldsku child on child.sku_id = sku.sku_id";
                sql += " where product_id in (" + prodIds + ") group by product_id";
                // Run query
                OracleCommand    command = new OracleCommand(sql, con);
                OracleDataReader reader;
                try {
                    con.Open();
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        try {
                            map.Add(reader.GetString(0), reader.GetString(1));
                        } catch (Exception e) {
                            // nothing to see here, duplicate map add
                        }
                    }
                } catch (Exception ex) {
                    // Shits broke yo
                    Console.WriteLine("ERROR: " + ex.Message);
                    Console.ReadKey();
                } finally {
                    con.Close();
                }
            }

            // refer to backup... really should clean this up
            icsList = icsListBackup;

            // Now map them dept_id's
            foreach (var s in map)
            {
                for (int i = 0; i < icsList.Count; i++)
                {
                    if (s.Key == icsList[i].productId)
                    {
                        icsList[i].dept = s.Value;
                    }
                }
            }

            // write csv
            if (File.Exists(Environment.CurrentDirectory + @"\out\MissingImages.csv"))
            {
                File.Delete(Environment.CurrentDirectory + @"\out\MissingImages.csv");
            }
            File.Create(Environment.CurrentDirectory + @"\out\MissingImages.csv").Close();

            using (StreamWriter sw = new StreamWriter(Environment.CurrentDirectory + @"\out\MissingImages.csv")) {
                for (int i = 0; i < icsList.Count; i++)
                {
                    sw.WriteLine(String.Format("{0},{1},{2},{3},{4},{5}", icsList[i].dept, ((img)icsList[i]).productId, ((img)icsList[i]).type, ((img)icsList[i]).color, ((img)icsList[i]).imageName, ((img)icsList[i]).nav_from));
                }
            }

            // Output
            logger.Info(String.Format("{0}/{1} images processed", count, icsList.Count));
        }