Пример #1
0
 public void sendImage(Bitmap bitmap)
 {
     try
     {
         string fileName      = createImageName() + ".jpg";
         string imageFilePath = Application.StartupPath.ToString() + "/" + chat.ChatId + "/" + fileName;
         bitmap.Save(imageFilePath, System.Drawing.Imaging.ImageFormat.Jpeg);
         FtpUpload ftpUpload = new FtpUpload(imageFilePath, uploadURL + "/" + fileName);
         operatorServiceAgent.SendFile(fileName, chat.ChatId, "start");
         string msg = string.Format("<span style=\"font-family: Arial;color:blue;font-weight: bold;font-size: 12px;\">{0} :</span><br/><span style=\"font-family: Arial;font-size: 12px;\"><img src='{1}' /></span><br />", operatorServiceAgent.CurrentOperator.NickName + "&nbsp;&nbsp;&nbsp;" + DateTime.Now.ToString("hh:mm:ss"), imageFilePath);
         chatMessageViewerControl1.AddText(msg);
         uploadTasks.Add(ftpUpload);
         ftpUpload.FileUploadProgress += new EventHandler <FileUploadProgressEventArgs>(ftpUpload_FileUploadProgress);
         ftpUpload.Start();
     }
     catch (ExternalException eex)
     {
         Trace.WriteLine("sendImage ExternalException:" + eex.Message);
         chatMessageViewerControl1.AddInformation("网络出现问题,暂时无法获取及发送消息");
         return;
     }
     catch (Exception ex)
     {
         Trace.WriteLine("sendImage exception:" + ex.Message);
         chatMessageViewerControl1.AddInformation("网络出现问题,暂时无法获取及发送消息");
         return;
     }
 }
Пример #2
0
        /// <summary>
        /// 上传文件控件
        /// </summary>
        /// <param name="fileFullPath">上传的文件全路径</param>
        /// <param name="saveURL">需要上传到Ftp目录URL</param>
        public FileUploadControl(string fileFullPath, string saveURL)
        {
            InitializeComponent();
            this.lblSpeed.Text     = "正在传输...";
            this.fileFullPath      = fileFullPath;
            this.fileName          = fileFullPath.Substring(fileFullPath.LastIndexOf("\\") + 1);
            this.ftpURL            = saveURL.EndsWith("/")? saveURL + fileName : saveURL + "/" + fileName;
            this.pictureBox1.Image = Common.GetFileIcon(fileFullPath).ToBitmap();
            FileInfo fileInfo = new FileInfo(this.fileFullPath);

            fileSize             = fileInfo.Length;
            progressBar1.Maximum = (int)fileSize;

            ftpUpload = new FtpUpload(this.fileFullPath, ftpURL);
            ftpUpload.FileUploadProgress += new EventHandler <FileUploadProgressEventArgs>(ftpUpload_FileUploadProgress);

            ftpUpload.Start();
        }
Пример #3
0
        public Build()
        {
            // The configuration ("Debug", etc.) defaults to "Release".
            var configuration = Cake.Argument("configuration", "Release");

            // Git .ignore file should ignore this folder.
            // Here, we name it "Releases" (default , it could be "Artefacts", "Publish" or anything else,
            // but "Releases" is by default ignored in https://github.com/github/gitignore/blob/master/VisualStudio.gitignore.
            var releasesDir = Cake.Directory("CodeCakeBuilder/Releases");

            Task("Clean")
                .Does(() =>
                {
                    // Avoids cleaning CodeCakeBuilder itself!
                    Cake.CleanDirectories("**/bin/" + configuration, d => !d.Path.Segments.Contains("CodeCakeBuilder"));
                    Cake.CleanDirectories("**/obj/" + configuration, d => !d.Path.Segments.Contains("CodeCakeBuilder"));
                    Cake.CleanDirectories(releasesDir);
                });

            Task("Restore-NuGet-Packages")
                .Does(() =>
                {
                    Cake.Information("Restoring nuget packages for existing .sln files at the root level.", configuration);
                    foreach (var sln in Cake.GetFiles("*.sln"))
                    {
                        Cake.NuGetRestore(sln);
                    }
                });

            Task("Build")
                .IsDependentOn("Clean")
                .IsDependentOn("Restore-NuGet-Packages")
                .Does(() =>
                {
                    Cake.Information("Building all existing .sln files at the root level with '{0}' configuration (excluding this builder application).", configuration);
                    foreach (var sln in Cake.GetFiles("*.sln"))
                    {
                        using (var tempSln = Cake.CreateTemporarySolutionFile(sln))
                        {
                            // Excludes "CodeCakeBuilder" itself from compilation!
                            tempSln.ExcludeProjectsFromBuild("CodeCakeBuilder");
                            Cake.MSBuild(tempSln.FullPath, new MSBuildSettings()
                                    .SetConfiguration(configuration)
                                    .SetVerbosity(Verbosity.Minimal)
                                    .SetMaxCpuCount(1));
                        }
                    }
                });
            Task("CopyFiles")
            .IsDependentOn("Unit-Tests")
            .Does(() =>
            {
                if (Cake.AppVeyor().IsRunningOnAppVeyor)
                {
                    var path = "./Wander.Server/";
                    var files = Cake.GetFiles(path + "*");
                    string tmp = "./tmp";

                    if (!Directory.Exists(tmp))
                    {
                        Directory.CreateDirectory(tmp);
                    }
                    else
                    {
                        Directory.Delete(tmp, true);
                        Directory.CreateDirectory(tmp);
                    }
                    DirectoryPath path2 = new DirectoryPath(path);
                    DirectoryPath d = new DirectoryPath(tmp + "/");
                    this.Cake.CopyDirectory(path2, d);

                    Directory.Delete(tmp + "/Properties", true);
                    Directory.Delete(tmp + "/obj", true);
                    Directory.Delete(tmp + "/Model", true);
                    Directory.Delete(tmp + "/Hubs", true);
                    this.Cake.DeleteFiles(tmp + "/*.cs");
                    this.Cake.DeleteFiles(tmp + "/*.csproj");

                }
                else
                {
                    Cake.Information("Not running on appveyor, skipping...");
                }
            });
            Task("Package")
            .IsDependentOn("CopyFiles")
            .Does(() =>
            {
                if (Cake.AppVeyor().IsRunningOnAppVeyor)
                {
                    string pswd = Environment.GetEnvironmentVariable("FTP_PASSWORD");
                    if (pswd != null)
                    {
                        string output = "./output";
                        if (!Directory.Exists(output))
                        {
                            Directory.CreateDirectory(output);
                        }
                        else
                        {
                            Directory.Delete(output, true);
                            Directory.CreateDirectory(output);
                        }
                        string tmp = "./tmp";
                        Cake.Information("Zipping...");

                        Cake.Zip(tmp + "/", output + "/build.zip");

                        Cake.Information("Deploying");

                        FtpUpload ftp = new FtpUpload(@"ftp://labo.nightlydev.fr/", "administrateur", pswd, "z", tmp);
                        ftp.Start();

                        Directory.Delete(tmp, true);
                        Directory.Delete(output, true);

                    }
                }

                else
                {
                    Cake.Information("Not running on appveyor, skipping...");
                }

            });

            Task("DBSetup")
                .IsDependentOn("Build")
                .Does(
                    () =>
                    {
                        string db = Cake.InteractiveEnvironmentVariable("DB_CONNECTION_STRING");
                        if (Cake.AppVeyor().IsRunningOnAppVeyor)
                        {
                            db = @"Server=(local)\SQL2014;Database=master;User ID=sa;Password=Password12!";
                        }

                        if (String.IsNullOrEmpty(db))
                            db =
                                @"Data Source=(localdb)\ProjectsV12;Initial Catalog=WanderDB;Integrated Security=True;";
                        Cake.Information("Using database: {0}", db);

                        SqlConnection conn = new SqlConnection(db);

                        string filePath = "Docs/BDD/create.sql";
                        if (System.IO.File.Exists(filePath))
                        {
                            string create = System.IO.File.ReadAllText(filePath);
                            string[] commands = create.Split(new string[] { "GO" }, StringSplitOptions.None);

                            IEnumerable<string> commandStrings = Regex.Split(create, @"^\s*GO\s*$",
                           RegexOptions.Multiline | RegexOptions.IgnoreCase);

                            conn.Open();
                            foreach (string commandString in commandStrings)
                            {
                                if (commandString.Trim() != "")
                                {
                                    using (var command = new SqlCommand(commandString, conn))
                                    {
                                        command.ExecuteNonQuery();
                                    }
                                }
                            }
                            conn.Close();
                        }

                    });

            Task("Unit-Tests")
                .IsDependentOn("DBSetup")
                .Does(() =>
                {
                    Cake.MSTest("**/bin/" + configuration + "/*.Tests.dll");
                });

            Task("Default").IsDependentOn("Package");
        }