Beispiel #1
0
        public void WasChangedExternally_WhenFileWasModified_ReturnsTrueUntilLoadIsPerformed()
        {
            var t = nameof(WasChangedExternally_WhenThereWasNoModification_ReturnsFalse);
            using (var file = TestFileName.Create(t, "x", Toml.FileExtension))
            {
                // Arrange
                File.WriteAllText(file, "x=0");
                var cfg = new FileConfig(new FileConfigSource(file));
                cfg.Load();
                using (var sw = File.AppendText(file))
                {
                    sw.WriteLine();
                    sw.WriteLine("y=1");
                }

                // Act
                var r1 = cfg.WasChangedExternally();
                var r2 = cfg.WasChangedExternally();
                cfg.Load();
                var r3 = cfg.WasChangedExternally();

                // Assert
                r1.Should().Be(true);
                r2.Should().Be(true);
                r3.Should().Be(false);
            }
        }
Beispiel #2
0
        public void WasChangedExternally_WhenThereWasNoModification_ReturnsFalse()
        {
            var t = nameof(WasChangedExternally_WhenThereWasNoModification_ReturnsFalse);
            using (var file = TestFileName.Create(t, "x", Toml.FileExtension))
            {
                // Arrange
                File.WriteAllText(file, "x=0");
                var cfg = new FileConfig(new FileConfigSource(file));
                cfg.Load();

                // Act
                var r = cfg.WasChangedExternally();

                // Assert
                r.Should().Be(false);
            }
        }
Beispiel #3
0
        public void WasChangedExternally_WhenFileWasNotLoadedAtLeastOnce_WillAlwaysReturnTrue()
        {
            var t = nameof(WasChangedExternally_WhenThereWasNoModification_ReturnsFalse);
            using (var file = TestFileName.Create(t, "x", Toml.FileExtension))
            {
                // Arrange
                File.WriteAllText(file, "x=0");
                var cfg = new FileConfig(new FileConfigSource(file));

                // Act
                var r1 = cfg.WasChangedExternally();
                var r2 = cfg.WasChangedExternally();

                // Assert
                r1.Should().Be(true);
                r2.Should().Be(true);
            }
        }
        public void Save_UpdatesInMemoryConfigSoNextLoadWillDeliverThatConfig()
        {
            using (var fn = TestFileName.Create(nameof(Save_UpdatesInMemoryConfigSoNextLoadWillDeliverThatConfig), "file", Toml.FileExtension))
            {
                // Arrange
                var fc = new FileConfig(new FileConfigSource(fn));
                var oc = new ReloadOnExternalChangeFileConfig(fc);
                File.WriteAllText(fn, "X = 1");
                oc.Load(); // At least one load needs to be done, otherwise a load will be done because not any data was loaded yet

                // Act
                oc.Save(Toml.ReadString("X = 2"));

                // Assert
                var readBack = oc.Load();
                ((TomlInt)readBack["X"]).Value.Should().Be(2);
            }
        }
Beispiel #5
0
 private void CopyFromFileConfig(FileConfig fc)
 {
     CopyFromTo(fc,this);
     return;
 }
        private static void Getx264Line(FileConfig fileConfig, int pass, out string x264Line, out string outputpath, bool ffmpegpipe = false)
        {
            VedioConfig vedioConfig = fileConfig.VedioConfig;

            x264Line = Resource1.x264Line;
            x264Line = x264Line.Replace("$preset$", vedioConfig.preset);

            if (vedioConfig.depth == 10)
            {
                if (fileConfig.InputType == InputType.VapoursynthScriptFile)
                {
                    x264Line = x264Line.Replace("$profile$", "--input-depth 10");
                }
                else
                {
                    x264Line = x264Line.Replace("$profile$", "");
                }
            }
            else
            {
                x264Line = x264Line.Replace("$profile$", "");
            }

            if (string.IsNullOrEmpty(vedioConfig.tune))
            {
                x264Line = x264Line.Replace("$tune$", "");
            }
            else
            {
                x264Line = x264Line.Replace("$tune$", "--tune " + vedioConfig.tune);
            }
            if (vedioConfig.BitType == EncoderBitrateType.crf)
            {
                x264Line = x264Line.Replace("$crf$", "--crf " + vedioConfig.crf.ToString());
            }
            else if (vedioConfig.BitType == EncoderBitrateType.twopass)
            {
                string          twopassstr = "--pass " + pass + " --bitrate " + vedioConfig.bitrate.ToString();
                x264ArgsManager manager    = new x264ArgsManager(x264Line);
                //提供索引
                //if (!string.IsNullOrEmpty(fileConfig.VedioFileFullName))
                //    if (File.Exists(fileConfig.VedioFileFullName + ".lwi") && manager.GetArgValue("demuxer") == "lavf")
                //    {
                //        twopassstr += " --index \"" + fileConfig.VedioFileFullName + ".lwi\" ";
                //    }
                //    else if (File.Exists(fileConfig.VedioFileFullName + ".ffindex") && manager.GetArgValue("demuxer") == "ffms")
                //    {
                //        twopassstr += " --index \"" + fileConfig.VedioFileFullName + ".ffindex\" ";
                //    }

                x264Line = x264Line.Replace("$crf$", twopassstr);
            }
            else if (vedioConfig.BitType == EncoderBitrateType.qp)
            {
                x264Line = x264Line.Replace("$crf$", "--qp " + vedioConfig.crf.ToString());
            }

            if (fileConfig.AudioConfig.Enabled && fileConfig.AudioConfig.CopyStream && fileConfig.UseBat)
            {
                x264Line = x264Line.Replace("$acodec$", "copy");
            }
            else
            {
                x264Line = x264Line.Replace("$acodec$", "none");
            }
            x264Line = x264Line.Replace("$csp$", vedioConfig.csp);

            if (ffmpegpipe || !vedioConfig.deinterlace || !vedioConfig.Resize)
            {
                x264Line = x264Line.Replace("$resize$", "");
            }
            else
            {
                string        vf     = "--vf ";
                List <string> vflist = new List <string>();
                if (vedioConfig.deinterlace)
                {
                    string deinterlace = "yadif:mode=2,order=" + (vedioConfig.scanorder ? "tff" : "bff");
                    vflist.Add(deinterlace);
                }
                if (vedioConfig.Resize)
                {
                    string resize = string.Format("resize:width={0},height={1},method=lanczos", vedioConfig.Width, vedioConfig.Height);
                    vflist.Add(resize);
                }
                x264Line = x264Line.Replace("$resize$", vf + string.Join("/", vflist));
            }

            outputpath = string.Empty;

            string fileExtension = "." + fileConfig.Muxer;
            string inputArg      = "";

            //if (fileConfig.AudioConfig.CopyStream || !fileConfig.AudioConfig.Enabled)
            //{
            //    outputpath = fileConfig.OutputFile + fileExtension;
            //    outputpath = FileUtility.GetNoSameNameFile(outputpath);
            //}
            //else
            //临时目录
            outputpath = FileUtility.AppendRandomName(Config.Temp, Path.GetFileNameWithoutExtension(fileConfig.VedioFileFullName) + ".h264");

            //}
            if (fileConfig.InputType == InputType.AvisynthScriptFile)
            {
                x264Line = x264Line.Replace("$input$", fileConfig.AvsFileFullName.Maohao());
            }
            else if (fileConfig.InputType == InputType.AvisynthScript || fileConfig.InputType == InputType.VapoursynthScriptFile)
            {
                x264Line = x264Line.Replace("$input$", "");
            }
            else
            {
                if (fileConfig.UseBat)
                {
                    x264Line = x264Line.Replace("$input$", "");
                    inputArg = " --input - --y4m ";
                }
                else if (fileConfig.VedioConfig.decoderMode == DecoderMode.self)
                {
                    x264Line = x264Line.Replace("$input$", fileConfig.VedioFileFullName.Maohao());
                }
                else
                {
                    x264Line = x264Line.Replace("$input$", fileConfig.VedioFileFullName.Maohao());
                }
            }

            x264Line = x264Line.Replace("$outputfile$", outputpath.Maohao());

            //string log = "--log-file \"" + Path.GetFileNameWithoutExtension(fileConfig.FullName) + "_x264.log\" --log-file-level info ";
            if (fileConfig.InputType == InputType.AvisynthScriptFile || fileConfig.InputType == InputType.AvisynthScript ||
                fileConfig.VedioConfig.BitType == EncoderBitrateType.twopass)
            {
                vedioConfig.UserArgs = vedioConfig.UserArgs.Replace("--demuxer lavf", "");
            }
            if (fileConfig.UseBat)
            {
                x264Line = x264Line.Replace("$userargs$", vedioConfig.UserArgs + inputArg);
            }
            else
            {
                x264Line = x264Line.Replace("$userargs$", vedioConfig.UserArgs);
            }
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SMT.Foundation.Log.Tracer.Debug("开始下载文件");
            try
            {
                //\SMT\OA\考勤管理\2010121702324784503941.JPG
                //string fileName = "123.jpg";//客户端保存的文件名
                bool IsThum = false;//是否下载缩略图、不经过解密处理开关
                if (Request["filename"] == null)
                {
                    return;
                }
                if (Request["flag"] != null)
                {
                    IsThum = true;
                }
                String fileurl = HttpUtility.UrlDecode(Request["filename"]);
                SMT.Foundation.Log.Tracer.Debug("下载文件地址:" + fileurl);
                string[] arrFilePath = fileurl.Split('\\');
                // string filePath = string.Format(SavePath, fileName.Split('|')[0], fileName.Split('|')[1],  fileName.Split('|')[2]+"\\"+fileName.Split('|')[3]); //context.Server.MapPath("Bubble.jpg");
                string filePath = "";
                if (arrFilePath.Length == 6)
                {
                    filePath = string.Format(FileConfig.GetCompanyItem(arrFilePath[1]).SavePath, arrFilePath[1], arrFilePath[2], arrFilePath[3] + "\\" + arrFilePath[4]);
                }
                else
                {
                    filePath = string.Format(FileConfig.GetCompanyItem(arrFilePath[1]).SavePath, arrFilePath[1], arrFilePath[2], arrFilePath[3] + "\\" + arrFilePath[4]) + "\\" + arrFilePath[arrFilePath.Length - 2];
                }
                string NewfilePath = "";
                if (!IsThum)
                {
                    NewfilePath = string.Format(FileConfig.GetCompanyItem(arrFilePath[1]).SavePath, arrFilePath[1], arrFilePath[2], arrFilePath[3] + "\\" + arrFilePath[5]);
                }
                else
                {
                    //缩略图没有进行加密操作所以还是显示原图
                    NewfilePath = string.Format(FileConfig.GetCompanyItem(arrFilePath[1]).SavePath, arrFilePath[1], arrFilePath[2], arrFilePath[3] + "\\" + arrFilePath[4]) + "\\" + arrFilePath[arrFilePath.Length - 2];
                }
                SMT.Foundation.Log.Tracer.Debug("下载真实文件地址NewfilePath:" + NewfilePath);
                string             saveFileName        = arrFilePath[arrFilePath.Length - 1];                 //获取文件名
                string             StrServicesFileName = arrFilePath[arrFilePath.Length - 2].Substring(0, 8); //取前面的作为解密字符串
                System.IO.FileInfo fileInfo            = new System.IO.FileInfo(filePath);
                if (fileInfo.Exists == true)
                {
                    string Key = StrServicesFileName;
                    if (!IsThum)
                    {
                        CryptoHelp.DecryptFile(filePath, NewfilePath, StrServicesFileName);
                    }
                    //System.IO.FileStream iStream = System.IO.File.OpenRead(NewfilePath);
                    long   dataToRead;
                    int    length;
                    byte[] buffer = new Byte[300000];
                    System.IO.FileStream iStream = new System.IO.FileStream(NewfilePath, System.IO.FileMode.Open,
                                                                            System.IO.FileAccess.Read, System.IO.FileShare.Read);

                    //   Total   bytes   to   read:
                    dataToRead = iStream.Length;

                    Response.ContentType = "application/octet-stream";

                    Response.Charset = "UTF-8";
                    Response.AddHeader("Content-Disposition", "attachment;   filename=" + System.Web.HttpUtility.UrlEncode(saveFileName, System.Text.Encoding.UTF8));
                    Response.AddHeader("Content-Length", dataToRead.ToString());
                    //   Read   the   bytes.
                    while (dataToRead > 0)
                    {
                        //   Verify   that   the   client   is   connected.
                        if (Response.IsClientConnected)
                        {
                            //   Read   the   data   in   buffer.
                            length = iStream.Read(buffer, 0, 300000);

                            //   Write   the   data   to   the   current   output   stream.
                            Response.OutputStream.Write(buffer, 0, length);

                            //   Flush   the   data   to   the   HTML   output.
                            Response.Flush();

                            buffer     = new Byte[300000];
                            dataToRead = dataToRead - length;
                        }
                        else
                        {
                            //prevent   infinite   loop   if   user   disconnects
                            dataToRead = -1;
                        }
                    }
                    if (iStream != null)
                    {
                        //Close   the   file.
                        iStream.Close();
                        iStream.Dispose();
                    }
                    //删除文件
                    if (!IsThum)
                    {
                        File.Delete(NewfilePath);
                    }
                }
                else
                {
                    System.Web.HttpContext.Current.Response.Write("<script>alert('该文件不存在!');</script>");
                }
                //context.Response.ContentType = "text/plain";
                //context.Response.Write("Hello World");
            }
            catch (Exception ex)
            {
                //   Trap   the   error,   if   any.
                Response.Write("下载出现异常Error   :   " + ex.Message);
                Response.Clear();
                Response.End();
            }
            finally
            {
                Response.Clear();
                Response.End();
            }
        }
Beispiel #8
0
 public FileController(FileConfig fileConfig)
 {
     _fileConfig = fileConfig;
 }
 public async Task <MailEntity> GetMailInfo()
 {
     return(await FileConfig.GetMailInfoAsync());
 }
Beispiel #10
0
        /// <summary>
        /// Read a mesh from the specified stream
        /// </summary>
        /// <param name="mesh"></param>
        /// <param name="stream"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public static void ReadInto(Mesh mesh, Stream stream, FileConfig config = null)
        {
            if (config == null)
                config = FileConfig.DefaultConfig();

            //we're not wrapping the reading into a using because we don't want it to close the stream when done
            var reader = new BinaryReader(stream);

            var sigBytes = reader.ReadBytes(3);
            var sigString = Iso8859.GetString(sigBytes);

            if (sigString != FILE_SIGNATURE)
                throw new Exception("Stream did not have the UNM file signature");

            //TODO: care about the version
            var version = reader.ReadByte();
            if (version != VERSION)
                throw  new Exception(string.Format("Version {0} cannot read file version {1}", VERSION, version));

            var chunkCount = reader.ReadInt32();
            for(int i = 0; i < chunkCount; i++)
            {
                ushort chunkID;
                try
                {
                    chunkID = reader.ReadUInt16();
                }
                catch (EndOfStreamException)
                {
                    //no more chunks
                    break;
                }
                var chunkLength = (int) reader.ReadUInt32();
                var chunkBytes = new byte[chunkLength];
                var chunkReadBytes = stream.Read(chunkBytes, 0, chunkLength);
                if (chunkReadBytes < chunkLength)
                {
                    Debug.LogError(
                        string.Format(
                            "[UnityMesh] Stream ended unexpectedly. Expected {0} bytes, read only {1} bytes. Chunk ID {2}",
                            chunkLength, chunkReadBytes, chunkID));
                    break;
                }
                Chunk chunk;
                if (config.TryGetChunk(chunkID, out chunk))
                {
                    try
                    {
                        chunk.Read(chunkBytes, mesh);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(string.Format("[UnityMesh] Failed to read chunk {0} : {1}. Skipping.",
                                                        chunk.GetType().Name, e));
                    }
                }
                else
                {
                    Debug.LogWarning(string.Format("[UnityMesh] Unknown Chunk ID {0}, {1} bytes. Skipping.", chunkID,
                                                    chunkLength));
                    stream.Seek(chunkLength, SeekOrigin.Current);
                }
            }
        }
Beispiel #11
0
 public static Mesh Read(Stream stream, FileConfig config = null)
 {
     var mesh = new Mesh();
     ReadInto(mesh, stream, config);
     return mesh;
 }
Beispiel #12
0
        /// <summary>
        /// Write to the specified stream
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="mesh"></param>
        /// <param name="config"></param>
        public static void Write(Stream stream, Mesh mesh, FileConfig config = null)
        {
            if (mesh == null)
                throw new Exception("Cannot write a null Mesh");

            if (config == null)
                config = FileConfig.DefaultConfig();

            var writer = new BinaryWriter(stream);
            try
            {
                writer.Write(Iso8859.GetBytes(FILE_SIGNATURE));

                writer.Write(VERSION);

                writer.Write(config.Chunks.Count());

                foreach (var chunk in config.Chunks)
                {
                    byte[] chunkBytes = null;
                    try
                    {
                        chunkBytes = chunk.Write(mesh);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(
                            string.Format("[UnityMesh] Failed to write chunk {0} : {1}. Skipping to next chunk.",
                                          chunk.GetType().Name, e));
                    }

                    //skip writing any of the data if we failed to get the chunk data
                    if (chunkBytes == null) continue;

                    writer.Write(chunk.InternalChunkID);
                    writer.Write((uint) chunkBytes.Length);
                    stream.Write(chunkBytes, 0, chunkBytes.Length);
                }
            }
            finally
            {
                //do not dispose the writer, as it closes the stream. merely flush it.
                writer.Flush();
            }
        }
Beispiel #13
0
        public void TestFileConfigExpectsInstanceAlike()
        {
            FileConfig fromFactory = Factory.GetFileConfig("a", "b");

            Assert.IsInstanceOf <FileConfig>(fromFactory);
        }
        /* JiraReportConfig file constructor */
        public JiraReportConfig(string config_file=null)
        {
            /* Init the variables */
            jira_config = new JiraConfig();
            file_config = new FileConfig();
            email_config = new EmailConfig();
            client_config = new List<ClientConfig>();
            template_config = new TemplateMarkup();

            if (config_file != null) {
                if (!LoadConfig(config_file)) {
                    Console.WriteLine("Unable to read XML config file: " + config_file);
                }
                else {
                    Console.WriteLine("XML config file parsed successfully");
                }
            }
        }
Beispiel #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //UploadService bb = new UploadService();
            //bb.CreateCompanyDirectory("703dfb3c-d3dc-4b1d-9bf0-3507ba01b716", "集团本部", "SMT");
            SMT.Foundation.Log.Tracer.Debug("开始上传文件时间:" + System.DateTime.Now.ToString());
            try
            {
                string         NewPath  = "";
                HttpPostedFile fileData = Request.Files["Filedata"];
                SMT.Foundation.Log.Tracer.Debug("开始上传文件的大小:" + fileData.ContentLength.ToString());
                SMT.Foundation.Log.Tracer.Debug("开始上传文件:" + fileData.FileName);
                string filePath    = "";
                string companyCode = ""; //公司代码
                string systemCode  = ""; //系统代码
                string modelCode   = ""; //模块代码
                string encryptName = ""; //加密字符串
                string strFileName = "";
                strFileName = fileData.FileName;
                UserFile model = null;

                string DownloadUrl = string.Concat(ConfigurationManager.AppSettings["DownLoadUrl"]);
                //获取用户身份,由用户名,密码组成
                string StrAuthUser = string.Concat(ConfigurationManager.AppSettings["FileUploadUser"]);
                //if (Request["path"] != null)
                //{
                //    filePath = Request["path"].ToString();
                //    SMT.Foundation.Log.Tracer.Debug("上传文件完成,路径:" + filePath);
                //}
                if (Request["companyCode"] != null)//公司代码
                {
                    companyCode = Request["companyCode"].ToString();
                    model       = FileConfig.GetCompanyItem(companyCode);
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件companyCode:" + companyCode);
                }
                if (Request["systemCode"] != null)//系统代码
                {
                    systemCode = Request["systemCode"].ToString();
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件systemcode:" + systemCode);
                }
                if (Request["modelCode"] != null)//模块代码
                {
                    modelCode = Request["modelCode"].ToString();
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件modlecode:" + modelCode);
                }
                if (Request["encryptName"] != null)//加密文件名
                {
                    encryptName = Request["encryptName"].ToString();
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件encryptName:" + encryptName);
                }
                if (fileData != null)
                {
                    //string path = ctx.Server.MapPath(ctx.Request["file"].ToString());
                    string strPath = string.Format(model.SavePath, companyCode, systemCode, modelCode);
                    if (!System.IO.Directory.Exists(strPath))
                    {
                        if (strPath.IndexOf("\\\\") == 0)
                        {
                            string FirstName    = "";
                            string UserName     = "";
                            string StrPwd       = "";
                            string ComputerName = "";
                            if (StrAuthUser.IndexOf(",") > 0)
                            {
                                FirstName    = StrAuthUser.Split(',')[0];
                                ComputerName = FirstName.Split('/')[0];
                                UserName     = FirstName.Split('/')[1];
                                StrPwd       = StrAuthUser.Split(',')[1];
                            }
                            LogonImpersonate imper   = new LogonImpersonate(UserName, StrPwd);
                            string           path    = @"Z:\" + companyCode + @"\" + systemCode + @"\" + modelCode;
                            string           OldPath = model.SavePath.Split('{')[0].TrimEnd('\\');
                            if (CreateDirectory(path, UserName, StrPwd, OldPath))
                            {
                                SMT.Foundation.Log.Tracer.Debug("aspx页面创建了驱动器映射");
                            }
                            else
                            {
                                SMT.Foundation.Log.Tracer.Debug("aspx页面有创建映射问题");
                            }
                        }
                        else
                        {
                            System.IO.Directory.CreateDirectory(strPath);
                        }
                    }
                    NewPath = Path.Combine(strPath, encryptName);            //还未上传完成的路径
                    string OldFilePath = Path.Combine(strPath, strFileName); //原来上传的文件
                    string PassWordKey = "";                                 //加密字符串
                    if (encryptName.Length > 8)
                    {
                        PassWordKey = encryptName.Substring(0, 8);
                    }
                    else
                    {
                        PassWordKey = "12345678";
                    }
                    int    fileLength = fileData.ContentLength;
                    byte[] data       = new Byte[fileLength];
                    Stream fileStream = fileData.InputStream;
                    fileStream.Read(data, 0, fileLength);

                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件开始,路径NewPath:" + NewPath);
                    using (FileStream fs = File.Create(NewPath))
                    {
                        fs.Write(data, 0, data.Length);
                        fs.Close();
                        fs.Dispose();
                    }
                    //创建上传过来的文件
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件开始,路径OldFilePath:" + OldFilePath);
                    using (FileStream fsOld = File.Create(OldFilePath))
                    {
                        fsOld.Write(data, 0, data.Length);
                        fsOld.Close();
                        fsOld.Dispose();
                    }

                    string strTempName = Path.Combine(strPath, encryptName);//已经上传完成的路径
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件开始,路径strTempName:" + strTempName);
                    File.Move(NewPath, strTempName);
                    NewPath = strTempName;//最近返回已完成的路径
                    string imageType = ".JPEG,.JPG,.GIF,.BMP";
                    //判断上传的模块的类型,如果是新闻则生成缩略图
                    #region 生成缩略图

                    string FileType = "";
                    if (imageType.IndexOf(FileType) > 0 || imageType.ToLower().IndexOf(FileType) > 0)
                    {
                        string thumbPath = string.Format(model.SavePath, companyCode, systemCode, modelCode) + "\\thumb\\";
                        SMT.Foundation.Log.Tracer.Debug("aspx页面上传图片文件,路径thumbPath:" + thumbPath);
                        if (!System.IO.Directory.Exists(thumbPath))
                        {
                            SMT.Foundation.Log.Tracer.Debug("aspx页面上传图片文件,不存在路径thumbPath:" + thumbPath);
                            if (strPath.IndexOf("\\\\") == 0)
                            {
                                string FirstName    = "";
                                string UserName     = "";
                                string StrPwd       = "";
                                string ComputerName = "";
                                if (StrAuthUser.IndexOf(",") > 0)
                                {
                                    FirstName    = StrAuthUser.Split(',')[0];
                                    ComputerName = FirstName.Split('/')[0];
                                    UserName     = FirstName.Split('/')[1];
                                    StrPwd       = StrAuthUser.Split(',')[1];
                                }
                                LogonImpersonate imper   = new LogonImpersonate(UserName, StrPwd);
                                string           path    = @"Z:\" + companyCode + @"\" + systemCode + @"\" + modelCode;
                                string           OldPath = model.SavePath.Split('{')[0].TrimEnd('\\');
                                if (CreateDirectory(path, UserName, StrPwd, OldPath))
                                {
                                    SMT.Foundation.Log.Tracer.Debug("创建了驱动器映射");
                                }
                                else
                                {
                                    SMT.Foundation.Log.Tracer.Debug("aspx页面图片上传有问题");
                                }
                            }
                            else
                            {
                                SMT.Foundation.Log.Tracer.Debug("aspx页面上传图片文件,开始创建路径thumbPath:" + thumbPath);
                                System.IO.Directory.CreateDirectory(thumbPath);
                            }
                        }
                        string thumbFile = thumbPath + encryptName;
                        string strType   = "JPG";
                        strType = FileType;
                        MakeImageThumb.MakeThumbnail(OldFilePath, thumbFile, 250, 200, "DB", strType);
                        //保存到数据库的路径
                        string strSaveThumb = string.Format("\\{0}\\{1}\\{2}", companyCode, systemCode, modelCode + "\\thumb\\" + encryptName);
                        //entity.THUMBNAILURL = string.Format("\\{0}\\{1}\\{2}", model.CompanyCode, model.SystemCode, model.ModelCode + "\\" + strMd5Name);
                        //entity.THUMBNAILURL = strSaveThumb;
                    }
                    #endregion
                    CryptoHelp.EncryptFileForMVC(OldFilePath, NewPath, PassWordKey);
                    //fileStream.Close();
                    //fileStream.Dispose();
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件完成,路径:" + NewPath + " tempName:" + strTempName);
                }
            }
            catch (Exception ex)
            {
                SMT.Foundation.Log.Tracer.Debug("上传文件upload.aspx页面出现错误:" + ex.ToString());
            }
        }
Beispiel #16
0
 public JsonFileHandlingService(ILogger <JsonFileHandlingService> logger, IOptions <FileConfig> fileConfig)
 {
     _logger     = logger;
     _fileConfig = fileConfig.Value;
 }
Beispiel #17
0
 public static void Demo()
 {
     InMemory.Demo();
     FileConfig.Demo();
 }
 public async Task <bool> SaveMailInfo([FromBody] MailEntity mailEntity)
 {
     return(await FileConfig.SaveMailInfoAsync(mailEntity));
 }
Beispiel #19
0
        public LeavingTransaction(String plateNumber, DateTime outTime, Byte[] outImg, Decimal copeMoney,
                                  Decimal actualMoney, UInt32 ticketId, Stream responseStream)
        {
            //TODO:Using record id which readed from db
            this.RecordId       = 0x00;
            this.PlateNumber    = plateNumber;
            this.OutTime        = outTime;
            this.OutImg         = outImg;
            this.CopeMoney      = copeMoney;
            this.ActualMoney    = actualMoney;
            this.TicketId       = ticketId;
            this.ResponseStream = responseStream;
            this.FullOutput     = FileConfig.FindConfig("Transaction.cfg").GetBoolean("FullOutput");

            this.WorkThread = new Thread(() =>
            {
                try
                {
                    DateTime start = DateTime.Now;
                    if (this.FullOutput)
                    {
                        Log.Info(String.Format("Leave started[+0ms]"));
                    }
                    //Pre-Storage messages and get record id
                    this.RecordId = Engine.GetEngine()
                                    .Storage.PreCarLeave(this.PlateNumber, this.OutTime, this.CopeMoney, this.ActualMoney,
                                                         this.TicketId);
                    if (this.FullOutput)
                    {
                        Log.Info(String.Format("Leave pre-leaved[+{0}ms]", (DateTime.Now - start).TotalMilliseconds));
                    }

                    //Calculate action
                    var successfullyChargedByUserBalance = this.RecordId != 0 &&
                                                           Engine.GetEngine()
                                                           .Storage.TryDeductBalance(this.RecordId,
                                                                                     this.ActualMoney);



                    Log.Info(String.Format("Leave Educted Balance[+{0}ms]",
                                           (DateTime.Now - start).TotalMilliseconds));



                    //Response F3!
                    String json;
                    if (successfullyChargedByUserBalance)
                    {
                        json =
                            IPSCMJsonConvert.ConvertToJson(new Result
                        {
                            ResultCode = ResultCode.Success
                        });
                    }
                    else
                    {
                        json =
                            IPSCMJsonConvert.ConvertToJson(new Result
                        {
                            ResultCode = ResultCode.SuccessButInsufficientFunds
                        });
                    }
                    StreamUtils.WriteToStreamWithUF8(this.ResponseStream, json);
                    this.ResponseStream.Flush();
                    this.ResponseStream.Close();
                    if (this.FullOutput)
                    {
                        Log.Info(String.Format("Leave responded to F3[+{0}ms]", (DateTime.Now - start).TotalMilliseconds));
                    }
                    //Used ticket
                    if (successfullyChargedByUserBalance && this.TicketId != 0)
                    {
                        Engine.GetEngine().Storage.UsedTicket(ticketId, outTime);
                    }
                    if (this.FullOutput)
                    {
                        Log.Info(String.Format("Leave ticket processed[+{0}ms]",
                                               (DateTime.Now - start).TotalMilliseconds));
                    }

                    //Send message to cloud
                    if (!successfullyChargedByUserBalance)
                    {
                        this.CopeMoney   = 0;
                        this.TicketId    = 0;
                        this.ActualMoney = 0;
                    }
                    var result = Engine.GetEngine()
                                 .CloudParking.Leaving(this.RecordId, this.PlateNumber, this.OutTime, this.OutImg, this.CopeMoney,
                                                       this.ActualMoney, this.TicketId);
                    if (this.FullOutput)
                    {
                        Log.Info(String.Format("Leave result received[+{0}ms]", (DateTime.Now - start).TotalMilliseconds));
                    }

                    switch (result.ResultCode)
                    {
                    case ResultCode.Success:
                        {
                            Engine.GetEngine().Storage.PostCarLeaved(this.PlateNumber, result);
                            break;
                        }

                    default:
                        {
                            Log.Error("Leaving transaction do not support Result code:" + result.ResultCode +
                                      " and wrong message is:" + result.ErrorMsg);
                            break;
                        }
                    }
                    this.Status = TransactionStatus.Exhausted;
                }
                catch (Exception ex)
                {
                    this.Status = TransactionStatus.Errored;
                    Log.Error("Leaving transtraction encountered a bad error!", ex);
                }
                finally
                {
                    this.ResponseStream.Flush();
                    this.ResponseStream.Close();
                }
            });
        }
 public async Task <MqttOptionsEntity> GetMqttSet()
 {
     return(await FileConfig.GetMqttSetAsync());
 }
 /// <summary>
 /// 配置项目中的文件配置
 /// </summary>
 /// <param name="fileConfig"></param>
 private void VarProjectFileConfig(FileConfig fileConfig)
 {
     MainLaserProject.FileList.Clear();//保证只有一个文件保存在工程中
     MainLaserProject.FileList.Add(new FileConfig(fileConfig));
 }
        public async Task <bool> SaveRabbitSet([FromBody] RabbitOptionsEntity input)
        {
            await FileConfig.SaveRabbitSetAsync(input);

            return(true);
        }
        public static string RunAvsx264mod(FileConfig fileConfig)
        {
            VedioConfig      vedioConfig = fileConfig.VedioConfig;
            ProcessStartInfo processinfo = new ProcessStartInfo();

            processinfo.UseShellExecute        = false; //输出信息重定向
            processinfo.CreateNoWindow         = true;
            processinfo.RedirectStandardInput  = true;
            processinfo.RedirectStandardOutput = true;
            processinfo.RedirectStandardError  = true;
            processinfo.WindowStyle            = ProcessWindowStyle.Hidden;

            processinfo.FileName = Path.Combine(Application.StartupPath, "tools\\avs4x264mod.exe");
            if (!File.Exists(processinfo.FileName))
            {
                throw new EncoderException("找不到指定程序:" + processinfo.FileName);
            }

            string x264exe = GetX264exeFullName(vedioConfig);

            if (!File.Exists(x264exe))
            {
                throw new EncoderException("找不到指定程序:" + x264exe);
            }
            string  x264Line;
            string  outputpath = "";
            Process avsx264mod = new Process();

            if (vedioConfig.BitType == EncoderBitrateType.crf)
            {
                Getx264Line(fileConfig, 0, out x264Line, out outputpath);
                string avsx264modarg = string.Format("--x264-binary \"{0}\" ", Path.GetFileName(x264exe));
                processinfo.Arguments = avsx264modarg + x264Line;
                avsx264mod.StartInfo  = processinfo;
                OutputToText(fileConfig, avsx264mod);
                avsx264mod.Start();
                avsx264mod.BeginOutputReadLine();
                avsx264mod.BeginErrorReadLine();
                avsx264mod.WaitForExit();
            }
            else if (vedioConfig.BitType == EncoderBitrateType.twopass)
            {
                Getx264Line(fileConfig, 1, out x264Line, out outputpath);
                string avsx264modarg = string.Format("--x264-binary \"{0}\" ", x264exe);
                processinfo.Arguments = avsx264modarg + x264Line;
                avsx264mod.StartInfo  = processinfo;
                OutputToText(fileConfig, avsx264mod);
                avsx264mod.Start();
                avsx264mod.BeginOutputReadLine();
                avsx264mod.BeginErrorReadLine();
                avsx264mod.WaitForExit();

                {
                    Process avsx264mod2 = new Process();
                    Getx264Line(fileConfig, 2, out x264Line, out outputpath);
                    avsx264modarg         = string.Format("--x264-binary \"{0}\" ", x264exe);
                    processinfo.Arguments = avsx264modarg + x264Line;
                    avsx264mod2.StartInfo = processinfo;
                    OutputToText(fileConfig, avsx264mod2);
                    avsx264mod2.Start();
                    avsx264mod2.BeginOutputReadLine();
                    avsx264mod2.BeginErrorReadLine();
                    avsx264mod2.WaitForExit();
                }
            }

            avsx264mod.Dispose();
            return(outputpath);
        }
 public async Task <RabbitOptionsEntity> GetRabbitSet()
 {
     return(await FileConfig.GetRabbitSetAsync());
 }
Beispiel #25
0
        public static string getFileConfig(string folder, string file)
        {
            FileConfig _fileTemplate = new FileConfig(folder, new TextParser());

            return(_fileTemplate.Parse <string>(file));
        }
Beispiel #26
0
 public LocalFileHandler(FileConfig config)
 {
     _fileConfig = config;
 }
Beispiel #27
0
 public UploaderController(FileConfig fileConfig)
 {
     _fileConfig = fileConfig;
 }
Beispiel #28
0
 public AutoniseApiLogHandler()
 {
     FileConfig.CSVConfigure();
     _logger = LogManager.GetCurrentClassLogger();
 }
Beispiel #29
0
 public void DefaultObject(DataTable tbl, string objectId)
 {
     if (!int.TryParse(objectId, out _objectId)) _objectId = 0;
     _isChanged = false;
     _isDefault = true;
     _table = tbl;
     //_row = null;
     var fc = new FileConfig();
     fc.SetDefaultValue();
     CopyFromFileConfig(fc);
     SetBindingElements();
 }
        public static void Apply(FileConfig configLocal, FileInstance file, Config.Config configGlobal)
        {
            var configTables = new[]
            {
                configGlobal.Tables, configLocal.Tables
            };

            foreach (var tables in configTables)
            {
                if (tables == null)
                {
                    continue;
                }

                foreach (var configTable in tables)
                {
                    if (!file.Tables.ContainsKey(configTable.Key))
                    {
                        Logger.LogErrorMessage(
                            $"Table: {configTable.Key} not found, while applying file level configuration");
                        continue;
                    }

                    var table = file.Tables[configTable.Key];


                    if (!string.IsNullOrEmpty(configTable.Value.NewName))
                    {
                        table.NewName = configTable.Value.NewName;
                    }

                    if (configTable.Value.IgnoreColumns != null)
                    {
                        ApplyIgnoreColumn(configTable.Value, table);
                    }

                    if (configTable.Value.NewColumns != null)
                    {
                        ApplyNewColumn(configTable.Value, table);
                    }

                    if (configTable.Value.Columns != null)
                    {
                        foreach (var column in configTable.Value.Columns)
                        {
                            if (!table.Columns.ContainsKey(column.Key))
                            {
                                Logger.LogErrorMessage(
                                    $"Column: {column.Key} not found in table {configTable.Key}, while applying file level configuration");
                                continue;
                            }

                            ApplyChange(configTable.Value, table, table.Columns[column.Key], file);
                        }
                    }

                    if (configTable.Value.DropColumns != null)
                    {
                        ApplyDropColumn(configTable.Value, table);
                    }

                    if (!string.IsNullOrEmpty(configTable.Value.ForceName))
                    {
                        foreach (var insert in table.Inserts)
                        {
                            insert.Table = configTable.Value.ForceName;
                        }
                        file.Tables.Add(configTable.Value.ForceName, table);
                        file.Tables.Remove(table.Name);
                        table.Name = configTable.Value.ForceName;
                    }
                }
            }
        }
Beispiel #31
0
 private void CopyToFileConfig(out FileConfig fc)
 {
     fc = new FileConfig();
     CopyFromTo(this, fc);
     return;
 }
Beispiel #32
0
 public NamingDecorator(FileConfig fileConfig)
 {
     this._fileConfig = fileConfig;
 }