public FileStreamResult TestDownload(string frdID, string FID)
        {
            Attatchment file = DB_Functions.GetFile(frdID, FID);

            if (file == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }


            //HttpResponseMessage gg = new HttpResponseMessage();
            string File_Name = "/" + file.Id + file.Owner.Replace("application/", ".");

            try
            {
                stream = new FileStream(Server.MapPath("~/Files") + File_Name, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            FileStreamResult fileStream = new FileStreamResult(stream, file.Owner);

            fileStream.FileDownloadName = file.Name;
            return(fileStream);
        }
예제 #2
0
 // Start is called before the first frame update
 void Start()
 {
     Att           = new Attatchment();
     EulerRotation = InitialLookDirection;
     rig           = GetComponent <Rigidbody>();
     LookDirection = InitialLookDirection;
 }
예제 #3
0
    void Attatch()
    {
        if (!Att.Attatched)                            // se não tiver um objeto ligado
        {
            Vector2 CurPanelindex = CurPanel.position; // pega a posição do jogador no grid

            if (MoveDirection(EulerRotation) != Direction.INVALID)
            {
                int       row         = (int)(CurPanelindex.x + EulerRotation.x); // pega o proximo baseado na direçao
                int       col         = (int)(CurPanelindex.y + EulerRotation.z); //que o jogador esta olhando
                GridPanel targetPanel = grid.thisgrid.getPanel(row, col);
                if (targetPanel != null)
                {
                    if (targetPanel.HasItem)// se o proximo tiver um objeto
                    {
                        if (!targetPanel.item.CanDrag)
                        {
                            return;
                        }
                        Direction dir = MoveDirection(EulerRotation);       //pega a orientação
                        Att = new Attatchment(true, dir, targetPanel.item); //cria novo Attatch com o objeto e orientação
                        Att.AttatchedObj.AttatchtoPlayer();
                        state = MoveState.Attatched;                        // muda o sistema do movimento
                    }
                }
            }
        }
    }
예제 #4
0
 public void ResetPlayer()
 {
     state = MoveState.FreeWalk;
     Att   = new Attatchment();
     playerStaff.ReturnStaff(this.transform);
     DroppingStaff = false;
 }
예제 #5
0
        public void GetAttatchments(ref List <Person> lstPersons)
        {
            int counter = 0;

            foreach (Person p in lstPersons)
            {
                bool clearCache = _source.clearcache ?? false;

                if ((counter == 0 || counter % 10 == 0) && clearCache)
                {
                    ClearCacheAndCookies();
                    RestartDriver(true);
                }

                if (!string.IsNullOrEmpty(p.URL))
                {
                    string className = string.Empty;
                    string attribute = string.Empty;

                    if (_source.detail != null)
                    {
                        className = (string)_source.detail.cssClass;
                        attribute = (string)_source.detail.attribute;
                    }

                    _driver.Navigate().GoToUrl(p.URL);
                    System.Threading.Thread.Sleep(1000);

                    Console.WriteLine(string.Format("_source: {0} / cssClass: {1} / attribute: {2}", p.Source, className, attribute));

                    try
                    {
                        string detail = _driver.FindElement(By.ClassName(className)).GetAttribute(attribute);

                        string id       = Guid.NewGuid().ToString();
                        string filetype = "html";

                        Attatchment attach = new Attatchment(id, p.Source, p.URL, filetype, detail, DateTime.Now);

                        p.Attatchments.Add(attach);
                    }
                    catch (Exception) {}
                }
            }
        }
예제 #6
0
        public List <Attatchment> FetchAttachementsData()
        {
            string  index   = _source.index;
            Elastic elastic = new Elastic(index);

            List <Attatchment> lstAttachments = new List <Attatchment>();

            int id = elastic.GetMaxId() + 1;

            Console.WriteLine("===> Max id:" + id);

            int maxRetries = _source.retries ?? 5;

            WebClient wc = new WebClient();

            bool end   = false;
            int  retry = 0;

            do
            {
                var tempFileName = Path.GetTempFileName();

                try
                {
                    string url = _source.url ?? "{0}";
                    url = string.Format(url, id++);
                    Console.WriteLine("=> Get " + url);

                    wc.DownloadFile(url, tempFileName);
                    var mimeType = wc.ResponseHeaders["content-type"];
                    Console.WriteLine("=> Mimetype " + mimeType);
                    var fileName = wc.ResponseHeaders["Content-Disposition"].Substring(wc.ResponseHeaders["Content-Disposition"].IndexOf("filename=") + 9).Replace("\"", "");
                    Console.WriteLine("=> Filename " + fileName);

                    if (string.IsNullOrEmpty(mimeType))
                    {
                        end = true;
                    }

                    var body = string.Empty;

                    if (fileName.ToLower().EndsWith(".pdf"))
                    {
                        var pdf = new PDFTextParser(new Toxy.ParserContext(tempFileName));
                        body = pdf.Parse();
                    }
                    else if (fileName.ToLower().EndsWith(".docx"))
                    {
                        System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
                        var docx = new Word2007TextParser(new Toxy.ParserContext(tempFileName));
                        body = docx.Parse();
                    }
                    else if (fileName.ToLower().EndsWith(".rtf"))
                    {
                        System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
                        var rtf = new RTFTextParser(new Toxy.ParserContext(tempFileName));
                        body = rtf.Parse();
                    }
                    else if (fileName.ToLower().EndsWith(".doc"))
                    {
                        System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
                        var doc = new Word2003TextParser(new Toxy.ParserContext(tempFileName));

                        body = doc.Parse();
                    }

                    if (!string.IsNullOrEmpty(body))
                    {
                        Attatchment attatch = new Attatchment(id.ToString(), fileName, url, mimeType, body, DateTime.Now);
                        elastic.SaveItem(attatch);
                    }
                    retry = 0;
                    //lstAttachments.Add(attatch);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    retry++;
                }

                try { File.Delete(tempFileName); }
                catch { } // best effort
                tempFileName = null;
            } while (!end && retry < maxRetries);

            return(lstAttachments);
        }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        Move();
        if (Input.GetKeyDown(KeyCode.Space) && !DroppingStaff)
        {
            if (!Att.Attatched)
            {
                Attatch();
            }
            else
            {
                Att.RemoveAttatch();
                Debug.Log(state);
                state = MoveState.FreeWalk;
            }
        }
        if (Att.Attatched)
        {
            if (Input.GetKeyDown(KeyCode.E))
            {
                Att.AttatchedObj.RotateObject(1);
            }

            else if (Input.GetKeyDown(KeyCode.Q))
            {
                Att.AttatchedObj.RotateObject(-1);
            }
        }

        if (Input.GetKeyDown(KeyCode.F) && !Att.Attatched)
        {
            if (!playerStaff.InGrid)
            {
                Direction curdir = MoveDirection(EulerRotation);
                if (curdir != Direction.INVALID)
                {
                    int       Row         = (int)(CurPanel.position.x + EulerRotation.x);
                    int       Col         = (int)(CurPanel.position.y + EulerRotation.z);
                    GridPanel targetPanel = grid.thisgrid.getPanel(Row, Col);
                    if (targetPanel == null || targetPanel.HasItem && targetPanel.item.objtype != ObjType.PRESSURE || targetPanel.Wall)
                    {
                        return;
                    }
                    DroppingStaff = true;

                    Vector3 targetpos = CurPanel.transform.position;
                    targetpos.y        = transform.position.y;
                    transform.position = targetpos;
                    playerStaff.DropStaff(targetPanel);
                    Att   = new Attatchment(true, curdir, playerStaff);
                    state = MoveState.Attatched;
                }
            }
            else
            {
                playerStaff.ReturnStaff(this.transform);
            }
        }
        else if (Input.GetKeyUp(KeyCode.F))
        {
            if (playerStaff.InGrid)
            {
                DroppingStaff = false;
                Att.RemoveAttatch();
                state = MoveState.FreeWalk;
            }
        }
    }