public override void Process(SendFile message)
        {
            var clientName = message.Sender;
            var nguoiNhan  = message.To;

            if (nguoiNhan == "*")
            {
                foreach (var item in clientManager.GetAll())
                {
                    this.Response.Add(new RecievedFile(clientName, item.TenMay, message.ByteData, message.FileName)
                    {
                        From = clientName, Client = item
                    });
                }
                return;
            }

            if (!clientManager.IsExist(nguoiNhan))
            {
                //Nếu người gửi không tồn tại
                this.Response.Add(new SendMessageFailed(clientName, "", "Người nhận không tồn tại:" + nguoiNhan));
            }
            else
            {
                this.Response.Add(new RecievedFile(clientName, nguoiNhan, message.ByteData, message.FileName)
                {
                    From = clientName, Client = clientManager.Get(nguoiNhan)
                });
            }
        }
Ejemplo n.º 2
0
 public SendFileView(SendFile file)
 {
     Id       = file.Id;
     Url      = file.Url;
     Size     = file.Size;
     SizeName = file.SizeName;
 }
Ejemplo n.º 3
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            SendFile file = new SendFile();
            string   filename;

            if ((filename = file.SetFile()) != null)
            {
                byte[] bytes = Encoding.UTF8.GetBytes("attachment");
                stream.Write(bytes, 0, bytes.Length);
                FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
                file.SetFile(fs.Name);
                file.FileName = getNameOfFile(fs.Name);
                file.FileSize = Convert.ToString(fs.Length);
                SendFileInfo(fs);
                SendFile(fs);
                fs.Close();
                file.Left = 285;
                CheckScrollBar();
                file.Top = getPosition();
                file.AddTimeLabelSender();
                panel3.Controls.Add(file);
                lastObject = file;
                filelist.Add(file);
            }
        }
Ejemplo n.º 4
0
        static void OnCreate(object sender, FileSystemEventArgs e)
        {
            Program.MainForm.TopMost = true;
            if (e.Name == Info.Folder.LOGIN_FILE_NAME)
            {
                if (Program.MainForm != null)
                {
                    Program.MainForm.BeginInvoke(new MethodInvoker(() =>
                    {
                        if (Addin.InSession)
                        {
                            Framework.Util.Forms.Show(typeof(MyAccount));
                        }
                        else
                        {
                            Framework.Util.Forms.Show(typeof(Login));
                        }
                    }));
                }
            }

            else if (e.Name == Info.Folder.SENDFILE_FILE_NAME)
            {
                if (Program.MainForm != null)
                {
                    Program.MainForm.BeginInvoke(new MethodInvoker(() =>
                    {
                        String path = e.FullPath;

                        if (File.Exists(path))
                        {
                            try
                            {
                                var info = File.ReadAllLines(path);
                                if (info != null && info.Length == 2)
                                {
                                    if (Addin.InSession)
                                    {
                                        SendFile form = new SendFile(info[0], info[1]);
                                        form.Show();
                                    }
                                    else
                                    {
                                        Login form = new Login(info[0], info[1]);
                                        form.Show();
                                    }
                                }
                            }
                            catch
                            { }
                        }
                    }));
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 启动文件发送系统;
        /// </summary>
        /// <param name="sendMust">IFileSendMust</param>
        /// <returns>IFileSend</returns>
        public static IFileSend StartFileSend(IFileSendMust sendMust)
        {
            if (fileSend != null)
            {
                throw new Exception("已经启动了文件发送系统;");
            }
            fileSend = new SendFile(sendMust);
            IFileSend IfileSend = fileSend;

            return(IfileSend);
        }
Ejemplo n.º 6
0
 public void AddRoute(string file, Regex path, Regex host = null)
 {
     AddRoute((stream, request) =>
     {
         var match    = path.Match(request.Uri);
         var subPath  = request.Uri.Substring(match.Length);
         var location = Path.Combine(file, subPath);
         try
         {
             SendFile(stream, new List <string> {
                 location
             }
                      .Concat(_config.DefaultFiles.Select(df => Path.Combine(location, df)))
                      .SkipWhile(f => !File.Exists(f))
                      .First());
         }
         catch (InvalidOperationException)
         {
             SendFile(stream, Path.Combine(_config.ErrorPagesDirectory, "404.html"), (404, "Not Found"));
         }
     }, path, host);
 }
Ejemplo n.º 7
0
        public async Task SendAsync(string userId, int homeworkId, string fileUri, string fileDescription)
        {
            var sendFile = new SendFile
            {
                CloudinaryFileUri = fileUri,
                FileDescription   = fileDescription,
                HomeworkId        = homeworkId,
                StudentId         = userId,
            };

            await this.sendFileRepository.AddAsync(sendFile);

            await this.sendFileRepository.SaveChangesAsync();
        }
Ejemplo n.º 8
0
        public object Any(SendFile request)
        {
            var response = new SendFileResponse {
                Name = request.Name,
            };

            if (base.Request.Files.Length > 0)
            {
                var file = base.Request.Files[0];
                response.FileSize = file.ContentLength;
            }

            return(response);
        }
Ejemplo n.º 9
0
 private void Runnable()
 {
     //65321 是服务端的端口
     String [] args = new String[] { "65321" };
     try
     {
         serverStarted = true;
         SendFile.Main_Send(args);
     }
     catch (Exception ex)
     {
         Log.Write(this.ToString(), ex);
     }
 }
Ejemplo n.º 10
0
        public async Task SendSolutionAsync(string studentId, int examId, string fileUri, string fileDescription)
        {
            var sendFile = new SendFile
            {
                CloudinaryFileUri = fileUri,
                FileDescription   = fileDescription,
                ExamId            = examId,
                StudentId         = studentId,
            };

            await this.sendFileRepository.AddAsync(sendFile);

            await this.sendFileRepository.SaveChangesAsync();
        }
Ejemplo n.º 11
0
        public void PopAndProcess()
        {
            var request = requestStack.Pop();

            if (File.Exists(request.FilePathAndName))
            {
                SendFile?.Invoke(this, request);
            }

            else
            {
                FileNotFound?.Invoke(this, request);
            }
        }
Ejemplo n.º 12
0
        public object Any(SendFile request)
        {
            var response = new SendFileResponse
            {
                Name = request.Name,
            };

            if (base.Request.Files.Length > 0)
            {
                var file = base.Request.Files[0];
                response.Result = $"Files: {Request.Files.Length}, name: {file.FileName}, size: {file.ContentLength} bytes";
            }

            return(response);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <returns></returns>
        public ActionResult DeleteData()
        {
            string res = "";

            if (Request["DeleteItem"] == null)
            {
                res = "参数错误!";
            }
            else
            {
                string   item     = Request["DeleteItem"].ToString();
                SendFile itemLine = JsonConvert.DeserializeObject <SendFile>(item);
                res = SendFileService.DeleteEntity(itemLine) ? "删除成功" : "删除失败";
            }
            return(Content(res));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 添加和修改
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveData()
        {
            bool     result    = false;
            string   dataitem  = Request["SendFileSet"];
            string   savetype  = Request["savetype"].ToString().Trim();
            SendFile model_lgt = JsonConvert.DeserializeObject <SendFile>(dataitem);

            if (savetype == "add")
            {
                SendFileService.AddEntity(model_lgt);
                result = true;
            }
            else if (savetype == "edit")
            {
                result = SendFileService.EditEntity(model_lgt);
            }
            return(Content(result.ToString()));
        }
Ejemplo n.º 15
0
 private int getPosition()
 {
     if (msglist.Count == 0 && receivelist.Count == 0 && photolist.Count == 0 && filelist.Count == 0 && audiolist.Count == 0 && videolist.Count == 0)
     {
         return(40);
     }
     if (lastObject is MyBubble)
     {
         MyBubble tmp = (MyBubble)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is GetBubble)
     {
         GetBubble tmp = (GetBubble)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is SendImage)
     {
         SendImage tmp = (SendImage)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is SendFile)
     {
         SendFile tmp = (SendFile)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is SendAudio)
     {
         SendAudio tmp = (SendAudio)lastObject;
         return(tmp.Top + tmp.Height);
     }
     if (lastObject is SendVideo)
     {
         SendVideo tmp = (SendVideo)lastObject;
         return(tmp.Top + tmp.Height);
     }
     else
     {
         return(0);
     }
 }
Ejemplo n.º 16
0
        private void BTN_Start_Click(object sender, EventArgs e)
        {
            int times = 0;

            SendFileRunning = true;

            if (RB_TestTimes.Checked)
            {
                times = Int32.Parse(TB_TestTimes.Text);
                Properties.Settings.Default.TestTimes = TB_TestTimes.Text;
                Properties.Settings.Default.TestMode  = "Times";
            }
            else
            {
                times = Int32.Parse(TB_TestMinutes.Text);
                Properties.Settings.Default.TestMinutes = TB_TestMinutes.Text;
                Properties.Settings.Default.TestMode    = "Minute";
            }

            Properties.Settings.Default.TestFile = TB_TestFile.Text;
            Properties.Settings.Default.Save();

            BTN_Start.Enabled = false;

            TB_Result.Text = "Performance @ " + System.DateTime.Now + ", File: " + Path.GetFileName(TB_TestFile.Text);
            Logger.Show(Logger.Level.Operation, TB_Result.Text);

            //Logger.mLevel = Logger.Level.Operation;
            SendFile aTransmission = new SendFile(port, TB_TestFile.Text, times, Properties.Settings.Default.TestMode, CB_LogFileEnable.Checked);

            aTransmission.updateUi = UpdateUi;
            aTransmission.taskDone = TaskDone;
            Thread t = new Thread(new ThreadStart(aTransmission.Run));

            t.Start();
        }
Ejemplo n.º 17
0
 private void timer1_Tick_1(object sender, EventArgs e)
 {
     if (gettedMessage != "")
     {
         ReceiveBubble(gettedMessage);
         gettedMessage = "";
     }
     if (path != "")
     {
         image = new SendImage();
         image.SetImage(path);
         image.Left       = 5;
         image.PhotoColor = Color.SkyBlue;
         image.Top        = getPosition();
         image.AddTimeLabelGetter();
         panel3.Controls.Add(image);
         lastObject = image;
         photolist.Add(image);
         path = "";
         CheckScrollBar();
     }
     if (filepath != "")
     {
         file = new SendFile();
         file.SetFile(filepath);
         file.FileName = filepath;
         file.FileSize = fileSizeString;
         file.Left     = 5;
         file.Top      = getPosition();
         file.AddTimeLabelGetter();
         panel3.Controls.Add(file);
         lastObject = file;
         filelist.Add(file);
         filepath = "";
         CheckScrollBar();
     }
     if (audiopath != "")
     {
         audio = new SendAudio();
         audio.SetFile(audiopath);
         audio.AudioTime = (GetWavFileDuration(audiopath)).ToString();
         audio.Left      = 5;
         audio.Top       = getPosition();
         audio.AddTimeLabelGetter();
         panel3.Controls.Add(audio);
         lastObject = audio;
         audiolist.Add(audio);
         audiopath = "";
         CheckScrollBar();
     }
     if (videopath != "")
     {
         wideo = new SendVideo();
         wideo.SetFile(videopath);
         wideo.Left = 5;
         wideo.Top  = getPosition();
         wideo.AddTimeLabelGetter();
         panel3.Controls.Add(wideo);
         lastObject = wideo;
         videolist.Add(wideo);
         videopath = "";
         CheckScrollBar();
     }
 }
Ejemplo n.º 18
0
 private void OnSendFile(SendFileEventArgs eventArgs)
 {
     SendFile?.Invoke(this, eventArgs);
 }
Ejemplo n.º 19
0
 public void ToevoegenBestand(SendFile file)
 {
     Generator.UpdateWachtrijRegel(file.Token, file.FileToken.ID, file.FileByteStream);
 }
Ejemplo n.º 20
0
        private void handle_sendFile(SendFile obj)
        {
            int ind = Utils.Helpers.fileInList(rec_files, obj.name);

            //check if the file is already in our list
            if (ind != -1)
            {
                rec_files[ind].queue.Enqueue(obj.file_part);
                rec_files[ind].rec += obj.file_part.Length;

                //update progress bar
                int ind2 = Utils.Helpers.downWindowIndex(downForms, obj.name);
                if (ind2 > -1 && downForms[ind2] != null)
                {
                    downForms[ind2].Invoke((MethodInvoker) delegate
                    {
                        downForms[ind2].update_rate_and_progress(obj.file_part.Length, obj.current_part, obj.parts, rec_files[ind].rec, rec_files[ind].size);
                        downForms[ind2].current_part = obj.current_part;
                    });
                }
            }
            else
            {
                //check if this part isn't a lost part (doesnt exist in list but doesn't start with the first part)
                if (obj.current_part == 0)
                {
                    lock (rec_files_Lock)
                    {
                        rec_files.Add(new tobe_file(obj.name, obj.file_part, obj.size, obj.file_part.Length));
                    }
                }
            }


            ind = Utils.Helpers.fileInList(rec_files, obj.name);
            if (obj.current_part < obj.parts - 1)
            { //file not fully received
                if (ind != -1 &&
                    rec_files[Utils.Helpers.fileInList(rec_files, obj.name)].paused == false)
                {
                    Send(new GetFile((obj.current_part + 1) + obj.name));
                }
            }
            else
            {//file received
                lock (rec_files_Lock) {
                    Utils.Helpers.buildFile(rec_files, obj.name);
                    int ind2 = Utils.Helpers.downWindowIndex(downForms, obj.name);
                    if (ind2 > -1 && downForms[ind2] != null)
                    {
                        downForms[ind2].Invoke((MethodInvoker) delegate {
                            downForms[ind2].finished              = true;
                            downForms[ind2].ProgressBar.Value     = 100;
                            downForms[ind2].label_downloaded.Text = "(100%)";
                            downForms[ind2].firefoxH23.Hide();
                            downForms[ind2].label_rate.Hide();
                            downForms[ind2].pause_download.Text = "Open";
                        });
                    }
                }
            }
        }