/// <summary>
        /// Processes the command.
        /// </summary>
        /// <param name="fileOperation">The file operation.</param>
        public void ProcessCommand(FileOperation fileOperation)
        {
            TraceService.WriteLine("FileOperationService::ProcessCommand");

            TraceService.WriteDebugLine("Platform=" + fileOperation.PlatForm);
            TraceService.WriteDebugLine("CommandType=" + fileOperation.CommandType);
            TraceService.WriteDebugLine("Directory=" + fileOperation.Directory);
            TraceService.WriteDebugLine("File=" + fileOperation.File);
            TraceService.WriteDebugLine("From=" + fileOperation.From);
            TraceService.WriteDebugLine("To=" + fileOperation.To);

            IProjectService projectService = this.visualStudioService.GetProjectServiceBySuffix(fileOperation.PlatForm);

            if (projectService != null)
            {
                IEnumerable<IProjectItemService> fileItemServices = this.GetFileItems(fileOperation, projectService);

                foreach (IProjectItemService projectItemService in fileItemServices)
                {
                    if (fileOperation.CommandType == "ReplaceText")
                    {
                        this.ReplaceText(fileOperation, projectService, projectItemService);
                    }
                    else if (fileOperation.CommandType == "Properties")
                    {
                        this.UpdateProperty(fileOperation, projectItemService);
                    }
                }
            }
            else
            {
                TraceService.WriteLine("Platform " + fileOperation.PlatForm + " not found");
            }
        }
示例#2
0
        public static void Queue(FileOperation operation, bool toTop = false)
        {
            if ((operation.Kind == TFileOperationKind.Copy || operation.Kind == TFileOperationKind.Move || operation.Kind == TFileOperationKind.Convert)
                && operation.DestMedia != null)
                operation.DestMedia.MediaStatus = TMediaStatus.CopyPending;
            if (operation.Kind == TFileOperationKind.Convert)
            {
                lock (_queueConvertOperation.SyncRoot)
                    if (!_queueConvertOperation.Any(fe => fe.Equals(operation)))
                    {
                        if (toTop)
                            _queueConvertOperation.Insert(0, operation);
                        else
                            _queueConvertOperation.Add(operation);
                        if (!_isRunningConvertOperation)
                        {
                            _isRunningConvertOperation = true;
                            ThreadPool.QueueUserWorkItem(o => _runOperation(_queueConvertOperation, ref _isRunningConvertOperation));
                        }
                    }
            }
            if (operation.Kind == TFileOperationKind.Export)
            {
                lock (_queueExportOperation.SyncRoot)
                    if (!_queueExportOperation.Any(fe => fe.Equals(operation)))
                    {
                        if (toTop)
                            _queueExportOperation.Insert(0, operation);
                        else
                            _queueExportOperation.Add(operation);
                        if (!_isRunningExportOperation)
                        {
                            _isRunningExportOperation = true;
                            ThreadPool.QueueUserWorkItem(o => _runOperation(_queueExportOperation, ref _isRunningExportOperation));
                        }
                    }

            }
            if (operation.Kind == TFileOperationKind.Copy
                || operation.Kind == TFileOperationKind.Delete
                || operation.Kind == TFileOperationKind.Loudness
                || operation.Kind == TFileOperationKind.Move)
            {
                lock (_queueSimpleOperation.SyncRoot)
                    if (!_queueSimpleOperation.Any(fe => fe.Equals(operation)))
                    {
                        if (toTop)
                            _queueSimpleOperation.Insert(0, operation);
                        else
                            _queueSimpleOperation.Add(operation);
                        if (!_isRunningSimpleOperation)
                        {
                            _isRunningSimpleOperation = true;
                            ThreadPool.QueueUserWorkItem(o => _runOperation(_queueSimpleOperation, ref _isRunningSimpleOperation));
                        }
                    }
            }
            if (OperationAdded != null)
                OperationAdded(operation);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="FileOperationResult" /> class.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="opperation">The opperation.</param>
 /// <param name="succeeded">if set to <c>true</c> [succeeded].</param>
 /// <param name="message">The message.</param>
 public FileOperationResult(string fileName, FileOperation opperation, bool succeeded, string message)
 {
     FileName = fileName;
     FileOperation = opperation;
     Succeeded = succeeded;
     Message = message;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="FileOperationResult" /> class.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="opperation">The opperation.</param>
 /// <param name="exception">The exception.</param>
 public FileOperationResult(string fileName, FileOperation opperation, Exception exception)
 {
     FileName = fileName;
     FileOperation = opperation;
     Succeeded = false;
     Message = exception.Message;
 }
示例#5
0
 public static void MoveDirectoryToRecycleBin(
     string directoryPath)
 {
     using (var fo = new FileOperation(new FileOperationProgressSink()))
     {
         fo.SetOperationFlags(FileOperationDeleteFlags);
         fo.DeleteItem(ZlpPathHelper.GetFullPath(directoryPath));
         fo.PerformOperations();
     }
 }
 private void OnOperationCompleted(FileOperation operation)
 {
     Application.Current.Dispatcher.BeginInvoke((Action)(() =>
     {
         if (_clearFinished)
         {
             foreach (FileOperationViewmodel vm in _operationList.ToList())
                 if (vm.IsFileOperation(operation))
                     _operationList.Remove(vm);
         }
     }), null);
 }
示例#7
0
文件: Menu.cs 项目: oleeq2/ToDo
        public bool FileOperationMenu(out FileOperation state,out string path)
        {
            bool ret;
            Console.Write("1. Load from file \n" +
                          "2. Save to file   \n" +
                          "> ");

            if (!FileOperation.TryParse(Console.ReadLine(), out state))
            {
                ret = false;
                path = string.Empty;
            }
            else
            {
                string tmp_path;
                ret = getPathMenu(state,out tmp_path);
                path = tmp_path;
            }
            return ret;
        }
示例#8
0
        public void LoadData(string path)
        {
            FileOperation fileOperation = new FileOperation();

            if (!fileOperation.CheckFileExists(path))
            {
                DataCollections.Add(new Data("", "", ""));

                try { fileOperation.CreateFile(path); }
                catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); }

                try { fileOperation.SaveFile(path, DataCollections); }
                catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); }
            }

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                try { path = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]; }
                catch { path = Environment.CurrentDirectory + "\\keys.pdk"; }
            }

            DataCollections = new FileOperation().OpenFile(path);
        }
示例#9
0
            public void SetUpSampleInputOperation()
            {
                var InputMessage       = "hello.";
                var InputCommiterName  = "Tsuyoshi Ushio";
                var InputCommiterEmail = "*****@*****.**";
                var InputContent       = "konichiwa.";
                var InputSha           = "qux";


                // public async Task UpdateFileContents(string owner, string repo, string path, FileOperation operation)
                this.InputOperation = new FileOperation
                {
                    message  = InputMessage,
                    commiter = new Commiter
                    {
                        name  = InputCommiterName,
                        email = InputCommiterEmail
                    },
                    branch  = this.InputBranch,
                    content = Convert.ToBase64String(Encoding.UTF8.GetBytes(InputContent)),
                    sha     = InputSha
                };
            }
示例#10
0
        /// <summary>
        /// 导入网关license文件
        /// </summary>
        /// <param name="license"></param>
        /// <returns></returns>
        public SmcErr ImportCGWLicense(string license)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new CgwError();

            if (this.licenseFileOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    FileOperation file = new FileOperation();
                    file.WriteFile(strPathLic, license);
                }
                catch (Exception ex)
                {
                    logEx.Error("ImportCGWLicense Exception:{0}", ex.ToString());
                }
                finally
                {
                    this.licenseFileOperateLock.ExitWriteLock();
                }
            }
            return(err);
        }
示例#11
0
        public JsonResult Submit()
        {
            if (!Permission.LoginedNeed(Request, Response, Session))
            {
                return(Json(false));
            }

            int    eid     = Convert.ToInt32(Request["eid"]);
            User   user    = (User)Session["user"];
            int    number  = Convert.ToInt32(Request["number"]);
            string content = "<exam>";

            for (var i = 1; i <= number; i++)
            {
                string answer = Request["q" + i];
                content += "<question><number>" + i + "</number><answer>" + answer + "</answer></question>";
            }
            content += "</exam>";

            string filename = Server.MapPath("/result/") + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + ".xml";

            if (!FileOperation.CreateFile(filename, content))
            {
                return(Json(false));
            }

            Result result = new Result
            {
                uid      = user.uid,
                eid      = eid,
                answer   = filename,
                reviewer = 1,
                score    = -1
            };

            return(Json(ResultView.AddResult(result)));
        }
示例#12
0
        public static string GetPath(string fileNameWithExtension, string root = "~",
                                     bool includeYearInPath = false, bool includeMonthInPath = false,
                                     bool includeDayInPath  = false, string objectId         = null,
                                     string urlPrefix       = null, string fileNamePrefix    = null)
        {
            #region Create Directory Address
            var persianDate = PersianDateTime.Now;
            var path        = string.Join("/", root);
            if (includeYearInPath)
            {
                path += "/" + persianDate.Year;
            }
            if (includeMonthInPath)
            {
                path += "/" + persianDate.Month;
            }
            if (includeDayInPath)
            {
                path += "/" + persianDate.Day;
            }
            path += (objectId == null ? string.Empty : ("/" + objectId));
            var directoryAddress = Path.Combine(Directory.GetCurrentDirectory(), urlPrefix ?? "", "wwwroot", path.Replace("/", "\\"));
            #endregion

            #region Create File Name
            var trustedFileName          = WebUtility.HtmlEncode(fileNameWithExtension);
            var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(trustedFileName);
            var fileName = fileNamePrefix != null ? fileNamePrefix + "_" : string.Empty;
            fileName += fileNameWithoutExtension + "_" + persianDate.Ticks.ToString() + Path.GetExtension(trustedFileName);
            #endregion

            if (!FileOperation.CreateDirectory(directoryAddress))
            {
                return(null);
            }
            return("wwwroot/" + path + "/" + fileName);
        }
        protected override void OnDragDropTarget(DragDropTargetEventArgs e)
        {
            e.HResult = ShellUtilities.S_OK;
            var paths = GetPaths(e);

            if (paths.Count > 0)
            {
                e.Effect = DragDropEffects.All;
            }

            if (e.Type == DragDropTargetEventType.DragDrop)
            {
                // file operation events need an STA thread
                WindowsUtilities.DoModelessAsync(() =>
                {
                    using (var fo = new FileOperation(true))
                    {
                        fo.PostCopyItem += (sender, e2) =>
                        {
                            // we could add some logic here
                        };

                        if (paths.Count == 1)
                        {
                            fo.CopyItem(paths[0], FileSystemPath, null);
                        }
                        else
                        {
                            fo.CopyItems(paths, FileSystemPath);
                        }
                        fo.SetOperationFlags(FOF.FOF_ALLOWUNDO | FOF.FOF_NOCONFIRMMKDIR | FOF.FOF_RENAMEONCOLLISION);
                        fo.PerformOperations();
                        NotifyUpdate();
                    }
                });
            }
        }
示例#14
0
        private void BtnJsonRestore_Click(object sender, EventArgs e)
        {
            List <string> etkilenenKayitlar = new List <string>();
            List <Parola> Parolalar         = null;
            string        path = FileOperation.FilePath();

            if (!string.IsNullOrEmpty(path))
            {
                string JsonOkunanData = System.IO.File.ReadAllText(path);
                Parolalar = JsonOperation.JsonDeserialize <Parola>(JsonOkunanData);
            }
            if (Parolalar != null && !string.IsNullOrEmpty(Parolalar[0].kullaniciadi) &&
                !string.IsNullOrEmpty(Parolalar[0].isim) && !string.IsNullOrEmpty(Parolalar[0].parola_) &&
                !string.IsNullOrEmpty(Parolalar[0].parola_))
            {
                foreach (var parola in Parolalar)
                {
                    //gelen koleksiyondaki verileri veritabanına kaydetmek için kod yazılabilir.
                    //ilgili değer kayıt ve update işlemleri yapılacaktır.
                    //business tarafında metotlar oluşturulup eklenecek..
                    string etkilenenenKayit = _bll.RestoreFromJsonToDatabase(parola);
                    if (etkilenenenKayit != "")
                    {
                        etkilenenKayitlar.Add(etkilenenenKayit);
                    }
                }
                MessageBoxOperation.MessageBoxInformation("Restore işlemi bitmiştir...");
                RestoreKayitlar restoreKayitlar = new RestoreKayitlar(etkilenenKayitlar);
                restoreKayitlar.Show();
            }
            else
            {
                //koleksiyon null değerde geldiği için herhangi bir işlem yapmıyoruz.
                MessageBoxOperation.MessageBoxWarning("Koleksiyon null değer almıştır.İlgili json dosyasından herhangi bir değer AKTARILAMAMIŞTIR.");
            }
            Listele();
        }
示例#15
0
 private void HttpDownload_DownloadCompletedEvent(DownloadThread thread)
 {
     lock (this)
     {
         bool flag = false;
         foreach (DownloadThread thr in threads)
         {
             if (thr.Equals(thread))
             {
                 continue;
             }
             if (!thr.Completed)
             {
                 flag = true;
             }
         }
         if (flag)
         {
             return;
         }
         if (Stop)
         {
             return;
         }
         string[] files = new string[threads.Length];
         for (int i = 0; i < threads.Length; i++)
         {
             files[i] = threads[i].DownloadPath;
         }
         State = TaskState.合并文件中;
         FileOperation.CombineFiles(files, FilePath + "\\" + FileName);
         Running      = false;
         TaskComplete = true;
         State        = TaskState.载完成;
         TaskCompletedEvent?.Invoke();
     }
 }
示例#16
0
 /// <summary>
 /// 加密链接字符串并保存到文件
 /// </summary>
 /// <param name="info"></param>
 /// <param name="key"></param>
 private void EncryptWriteInfo(string info, string guid, string key, bool isSys)
 {
     try
     {
         StringBuilder builder = new StringBuilder();
         FileOperation file    = new FileOperation();
         file.FilePath = _filePath;
         if (!File.Exists(_filePath))
         {
             FileStream fi = File.Create(_filePath);
             fi.Close();
         }
         string content = file.ReadFile();
         //builder.Append(content);
         builder.Append(SysConstManage.DBInfoArraySeparator);
         builder.Append(string.Format("{0}{1}", isSys ? key : guid, SysConstManage.ColonChar));
         builder.Append(DesCryptFactory.EncryptString(info, key));
         builder.Append(SysConstManage.DBInfoArraySeparator2);
         if (isSys)
         {
             builder.Append(content);
             file.WritText(builder.ToString());
         }
         else
         {
             file.WritText(string.Format("{0}{1}", content, builder.ToString()));
         }
         ExceptionMessage = file.ExceptionMessage;
     }
     catch (Exception ex)
     {
         ExceptionMessage = ex.Message;
     }
     finally
     {
     }
 }
示例#17
0
        public void LoadMotionSettings()
        {
            string strread   = "";
            string headerStr = "";

            for (int i = 0; i < AxisPara.Count; i++)
            {
                headerStr = "Axis" + (i + 1).ToString();
                //FileOperation.ReadData(motionSettingsFilePath, headerStr, "AxisID", ref strread);
                //AxisPara[i].AxisIdx = (Axislist)int.Parse(strread);

                FileOperation.ReadData(motionSettingsFilePath, headerStr, "HomeSpeed", ref strread);
                if (strread != "0")
                {
                    AxisPara[i].HomeSpeed = int.Parse(strread);
                }

                FileOperation.ReadData(motionSettingsFilePath, headerStr, "RunSpeed", ref strread);
                if (strread != "0")
                {
                    AxisPara[i].RunSpeed = int.Parse(strread);
                }

                FileOperation.ReadData(motionSettingsFilePath, headerStr, "MotorScale", ref strread);
                if (strread != "0")
                {
                    AxisPara[i].MotorScale = int.Parse(strread);
                }

                FileOperation.ReadData(motionSettingsFilePath, headerStr, "IsServoMotor", ref strread);
                if (strread != "0")
                {
                    AxisPara[i].IsServoMotor = bool.Parse(strread);
                }
            }
        }
示例#18
0
        //成功连接到客户端
        public static void AcceptCallback(IAsyncResult ar)
        {
            try
            {
                //把非终止状态改为终止状态
                allDone.Set();

                //从AsyncState中获取监听对象
                Socket listener = (Socket)ar.AsyncState;

                //客户端Socket
                Socket handler = listener.EndAccept(ar);

                StateObject state = new StateObject();
                state.workSocket = handler;
                FileOperation.WriteAppenFile(string.Format("连接成功,{0} 等待接收数据", listener.LocalEndPoint));
                //开始接收客户端的数据 将数据存储到state对象的buffer中
                handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state);
            }
            catch (Exception ex)
            {
                FileOperation.WriteAppenFile("2" + ex.Message);
            }
        }
        public ProcessingUserControlViewModel(MainWindow mainWindow, ProcessingUserControl userControl)
        {
            EnabledFilters = new List <ImageEffect>();
            Filters        = new List <ImageEffect>
            {
                { new ImageEffect(FilterType.Invert, "Invert Image") },
                { new ImageEffect(FilterType.SepiaTone, "Sepia Tone") },
                { new ImageEffect(FilterType.Emboss, "Emboss") },
                { new ImageEffect(FilterType.Emboss45Degree, "Emboss 45 Degree") },
                { new ImageEffect(FilterType.EmbossTopLeft, "Emboss Top Left") },
                { new ImageEffect(FilterType.EmbossIntense, "Emboss Intense") },
                { new ImageEffect(FilterType.Pixelate, "Pixelate", 1, 100, 1) },
                { new ImageEffect(FilterType.Median, "Median", 3, 19, 2) },
                { new ImageEffect(FilterType.BoxBlur, "Box Blur", 3, 19, 2) },
                { new ImageEffect(FilterType.GaussianBlur, "Gaussian Blur", 1, 100, 1) },
                { new ImageEffect(FilterType.EdgeDetection, "Edge Detection") },
                { new ImageEffect(FilterType.EdgeDetection45Degree, "Edge Detection 45 Degree") },
                { new ImageEffect(FilterType.EdgeDetectionHorizontal, "Edge Detection Horizontal") },
                { new ImageEffect(FilterType.EdgeDetectionVertical, "Edge Detection Vertical") },
                { new ImageEffect(FilterType.EdgeDetectionTopLeft, "Edge Detection Top Left") }
            };

            MaximumHue   = 360;
            Contrast     = 1;
            Gamma        = 1;
            showChanges  = true;
            PixelColor   = Color.FromArgb(255, 255, 0, 0);
            imageEffects = true;

            MainWindow    = mainWindow;
            UserControl   = userControl;
            manipulation  = new Manipulation();
            fileOperation = new FileOperation();

            manipulation.ImageFinished += OnImageFinished;
        }
示例#20
0
        public void BeginRequest(object sender, EventArgs e)
        {
            HttpApplication application = sender as HttpApplication;
            HttpContext     context     = application.Context;
            var             request     = context.Request;

            if (request.HttpMethod.ToLower().Equals("put") && request.Path.ToLower().Equals("/nuget/"))
            {
                var result = false;
                try
                {
                    var temporaryFile = Path.GetTempFileName();
                    var tempDir       = Path.GetTempPath() + Path.GetRandomFileName();

                    request.Files[0].SaveAs(temporaryFile);
                    ZipFile.ExtractToDirectory(temporaryFile, tempDir);

                    var files = new List <string>();
                    FileOperation.GetFiles(tempDir, "*.dll", ref files);

                    result = CheckFiles(files);

                    File.Delete(temporaryFile);
                    DirectoryInfo di = new DirectoryInfo(tempDir);
                    di.Delete(true);
                }
                catch (Exception exception)
                {
                }

                if (!result)
                {
                    EndRequest(context);
                }
            }
        }
 void OnGUI()
 {
     anim = (Animation)EditorGUILayout.ObjectField(anim, typeof(Animation));
     if (anim != null)
     {
         if (anim.clip != null)
         {
             EditorGUILayout.LabelField("当前的Clip是:" + anim.clip.name);
             if (FileOperation.showIOPath("复制动画clip到这里:", ref savePath, false, true, anim.clip.name, "anim"))
             {
                 if (!savePath.Contains(Application.dataPath))
                 {
                     EditorUtility.DisplayDialog("警告", "目前不允许使用这个路径,请先将文件保存到项目的Assets目录下面(任意位置任意深度),然后复制到电脑任意位置就随你的便", "OK");
                     return;
                 }
                 DoExport();
             }
         }
         else
         {
             EditorGUILayout.LabelField("当前的Clip为空,请先到Animation组件上设置");
         }
     }
 }
        public void InitializeTransfer(Queue <QueueItem> queue, FileOperation mode)
        {
            _queue = queue;
            _paneCache.Clear();
            _isPaused                    = false;
            _isAborted                   = false;
            _isContinued                 = false;
            _deleteAll                   = false;
            _skipAll                     = null;
            UserAction                   = mode;
            TransferAction               = mode == FileOperation.Copy ? GetCopyActionText() : Resx.ResourceManager.GetString(mode.ToString());
            _rememberedCopyAction        = CopyAction.CreateNew;
            _currentFileBytesTransferred = 0;
            CurrentFileProgress          = 0;
            FilesTransferred             = 0;
            FileCount                    = _queue.Count;
            BytesTransferred             = 0;
            TotalBytes                   = _queue.Where(item => item.FileSystemItem.Type == ItemType.File).Sum(item => item.FileSystemItem.Size ?? 0);
            Speed         = 0;
            ElapsedTime   = new TimeSpan(0);
            RemainingTime = new TimeSpan(0);

            WorkHandler.Run(BeforeTransferStart, BeforeTransferStartCallback);
        }
示例#23
0
        public void LoadTestCriteria(string fileName)
        {
            for (int SpecIdx = 0; SpecIdx < SpecList.Count; SpecIdx++)
            {
                string Header  = "Spectrometer" + (SpecIdx + 1).ToString();
                string strread = "";

                FileOperation.ReadData(fileName, Header, "CriteriaCount", ref strread);
                int cCnt = int.Parse(strread);
                SpecList[SpecIdx].Criteria.Clear();

                for (int i = 0; i < cCnt; i++)
                {
                    TestCriteria cri = new TestCriteria();
                    FileOperation.ReadData(fileName, Header, "CriteriaWL" + (i + 1).ToString(), ref strread);
                    cri.WaveLength = int.Parse(strread);
                    FileOperation.ReadData(fileName, Header, "CriteriaMin" + (i + 1).ToString(), ref strread);
                    cri.Min = double.Parse(strread);
                    FileOperation.ReadData(fileName, Header, "CriteriaMax" + (i + 1).ToString(), ref strread);
                    cri.Max = double.Parse(strread);
                    SpecList[SpecIdx].Criteria.Add(cri);
                }
            }
        }
示例#24
0
        // public OdbcConnection conn;

        //根据项目编号获取数据库信息
        public static LinkAttr GetLinkAttr(int xmno)
        {
            try
            {
                string    sql   = string.Format("select * from linkattr where xmno = {0}", xmno);
                DataTable dt    = SqlHelper.GetTable(sql);
                DataRow   row   = dt.Rows[0];
                LinkAttr  model = new LinkAttr()
                {
                    uid      = row["uid"].ToString(),
                    pwd      = row["pwd"].ToString(),
                    server   = row["server"].ToString(),
                    port     = int.Parse(row["port"].ToString()),
                    database = row["database"].ToString(),
                    driver   = row["driver"].ToString()
                };
                return(model);
            }
            catch (Exception ex)
            {
                FileOperation.WriteAppenFile(string.Format("获取项目编号为{0}的数据库连接信息出错, {1}", xmno.ToString(), ex.Message));
                return(null);
            }
        }
示例#25
0
 private void SearchPanelButton_Click(object sender, EventArgs e)
 {
     try
     {
         ActiveEmployee = FileOperation.GetByEmpId(int.Parse(SearchText.Text))[0];
     }
     catch
     {
         MessageBox.Show("ID Non Existant");
         return;
     }
     if (ActiveEmployee != null)
     {
         ActiveUID = int.Parse(SearchText.Text);
         SearchNameButton.Enabled         = true;
         SearchIDButton.Enabled           = true;
         SearchHiringDateButton.Enabled   = true;
         SearchDepartmentNoButton.Enabled = true;
         SearchValueName.Text             = ActiveEmployee.Name;
         SearchValueID.Text           = ActiveEmployee.Id.ToString();
         SearchValueHirinDate.Text    = ActiveEmployee.HireDate.ToShortDateString();
         SearchValueDepartmentNo.Text = ActiveEmployee.DepId.ToString();
     }
     else
     {
         SearchNameButton.Enabled         = false;
         SearchIDButton.Enabled           = false;
         SearchHiringDateButton.Enabled   = false;
         SearchDepartmentNoButton.Enabled = false;
         SearchValueName.Text             = "--------";
         SearchValueID.Text           = "--------";
         SearchValueHirinDate.Text    = "--------";
         SearchValueDepartmentNo.Text = "--------";
         //buttons need to be reset....
     }
 }
示例#26
0
        void SpeedStatistics()
        {
            long back = 0;

            while (true)
            {
                if (back == 0)
                {
                    back = downloadLength;
                }
                else
                {
                    speed = downloadLength - back;
                    back  = downloadLength;
                }
                if (Complete >= threads.Length)
                {
                    if (Stop)
                    {
                        break;
                    }
                    string[] files = new string[threads.Length];
                    for (int i = 0; i < threads.Length; i++)
                    {
                        files[i] = threads[i].FileName;
                    }
                    State = "拼接文件中";
                    FileOperation.CombineFiles(files, FilePath + "\\" + FileName);
                    Running      = false;
                    TaskComplete = true;
                    State        = "下载完成";
                    break;
                }
                Thread.Sleep(1000);
            }
        }
示例#27
0
        /// <summary>
        /// 获取默认打印样式文件
        /// </summary>
        /// <returns></returns>
        string GetDefaultStyleFile()
        {
            //判断是否有样式对象或数据
            //if (string.IsNullOrEmpty(styleObject) || dt == null || dt.Rows.Count == 0)
            //{
            //    return null;
            //}
            ////获取样式对象的打印样式列表
            //DataTable dtStyle = DBHelper.GetTable("", "tb_print_style", "style_url,style_name", string.Format("style_object='{0}'", styleObject), "", "");
            //if (dtStyle == null || dtStyle.Rows.Count == 0)
            //{
            //    return null;
            //}
            ////默认样式url
            //string defaultStyle = CommonCtrl.IsNullToString(dtStyle.Rows[0]["style_url"]);
            //if (defaultStyle.Length == 0)
            //{
            //    return null;
            //}
            //下载默认样式并得到本地样式路径
            string fileName = FileOperation.DownLoadFileByFile(styleObject, "Report");

            return(fileName);
        }
示例#28
0
        public static void StartListening(int port)
        {
            try
            {
                byte[]     bytes         = new Byte[1024];
                TcpBLL     bll           = new TcpBLL();
                string     ip            = bll.GetIp();
                IPAddress  ipAddress     = IPAddress.Parse(ip);
                IPEndPoint localEndPoint = new IPEndPoint(ipAddress, port);

                //启动tcp类型的监听
                Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                //绑定指定的额ip地址和端口
                listener.Bind(localEndPoint);
                //最多同时连接100台设备
                listener.Listen(100);
                while (true)
                {
                    allDone.Reset();
                    string info = "启动成功" + localEndPoint.Address.ToString() + ":" + localEndPoint.Port.ToString() + "等待连接...";
                    FileOperation.WriteAppenFile(info);

                    //开启监听
                    listener.BeginAccept(new AsyncCallback(AcceptCallback), listener);
                    allDone.WaitOne();
                }
            }
            catch (Exception e)
            {
                string info = e.Message;
                FileOperation.WriteAppenFile("1" + info);
            }

            Console.Read();
        }
示例#29
0
文件: Form1.cs 项目: Loong-Lee/VSDT
        private void buttonRead_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == "")
            {
                FolderBrowserDialog folddiag = new FolderBrowserDialog();
                if (folddiag.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                textBox1.Text = folddiag.SelectedPath;
            }
            string path = textBox1.Text; // @"F:\新建文件夹 (2)\Debug_MQ_99627\MQ";

            FileOperation myFileOper = new FileOperation();

            textBox1.Text = path;

            ArrayList list = myFileOper.GetAllDirFileList(new DirectoryInfo(path), "*.cs");

            for (int i = 0; i < list.Count; i++)
            {
                //当前文件名称
                string curFileName = list[i].ToString();
                //文件内容
                string mainFileContent = myFileOper.GetAllFileContent(curFileName);

                mainFileContent = mainFileContent.Replace("\r\n", "\n");
                string tmp = mainFileContent;
                //替换  /* */  注释
                ReplaceRemarkCode("\\S*k__BackingField", ref mainFileContent);
                if (tmp != mainFileContent)
                {
                    myFileOper.CreateFile(curFileName, mainFileContent);
                }
            }
        }
示例#30
0
        public void LoadSettings(string fileName)
        {
            string Header  = "";
            string strread = "";

            Header = "Barcode" + Name;

            FileOperation.ReadData(fileName, Header, "IP", ref strread);
            IP = strread;

            //FileOperation.ReadData(fileName, Header, "CommandPort", ref strread);
            //CommandPort = int.Parse(strread);

            FileOperation.ReadData(fileName, Header, "Port", ref strread);
            Port = int.Parse(strread);

            if (Para.MachineOnline)
            {
                if (!Connect(IP, Port))
                {
                    MessageBox.Show(Name + " can't be connected.");
                }
            }
        }
示例#31
0
	void DoFileOperation(FileOperation operation, UserMadeChoiceEventArgs e, string singleEntry)
	{
		if (operation == FileOperation.Nothing)
			return;

		string source = this.curPath;
		string target = targetFolder.Text;
		try
		{
			target = target.Trim().Trim('/', '\\');
			target = BXPath.ToVirtualRelativePath(target);
		}
		catch
		{
			ShowError(Encode(string.Format(GetMessageRaw("FormattedErrorMassage.SpecifiedPathIsInvalid"), targetFolder.Text)));
			return;
		}

		List<string> files;
		if (e == null)
		{
			if (singleEntry == null)
				return;
			files = new List<string>();
			files.Add(singleEntry);
		}
		else
			files = FormFileList(e);

		if (files.Count == 0)
			return;

		this.errorTemplateNoRightsToDelete = String.Format("{0}: {{0}}", GetMessageRaw("Message.InsufficientRightsToDelete"));
		this.errorTemplateUnknownSource = String.Format("{0}: {{0}}", GetMessageRaw("Message.UnknownItem"));
		this.errorTemplateUnableToDelete = String.Format("{0}: {{0}}", GetMessageRaw("Message.UnableToDelete"));
		this.errorTemplateTargetExists = String.Format("{0}: {{0}} -> {{1}}", GetMessageRaw("Message.TargetItemAlreadyExists"));
		this.errorTemplateUnableToWrite = String.Format("{0}: {{0}} -> {{1}}", GetMessageRaw("Message.UnableToWrite"));
		this.errorTemplateCantCopyIntoItself = String.Format("{0}: {{0}} -> {{1}}", GetMessageRaw("Message.CantCopyIntoItself"));

		if ((operation & FileOperation.Copy) > 0 && !CheckForCopyOperation(source, target))
			return;

		for (int i = 0; i < files.Count; i++)
		{
			try
			{
				string filename = files[i];
				string sourcePath = BXPath.Combine(source, filename);

				bool isFile;
				if (BXSecureIO.FileExists(sourcePath))
					isFile = true;
				else if (BXSecureIO.DirectoryExists(sourcePath))
					isFile = false;
				else
					throw new Exception(String.Format(this.errorTemplateUnknownSource, sourcePath));

				if ((operation & FileOperation.Copy) > 0)
					DoFileCopyMove(sourcePath, BXPath.Combine(target, filename), (operation & FileOperation.Delete) > 0, isFile);
				else if ((operation & FileOperation.Delete) > 0)
					DoFileDelete(sourcePath, isFile);
			}
			catch (Exception ex)
			{
				ShowError(Encode(ex.Message));
			}
		}
		ShowOk();
		fileManGrid.MarkAsChanged();
	}
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="operation">The type of file operation.</param>
 /// <param name="operatorType">The type of the operator.</param>
 public BreakOperation(FileOperation operation, OperatorType operatorType)
 {
     this.Operation = operation;
     this.Operator = operatorType;
 }
        public void FileOperationToBreakLeaseRequest(FileOperation operation, OperatorType operatorType, ModelDialectRevision dialect, out LeasingConfig c)
        {
            c = leasingConfig;

            LeasingClientInfo clientInfo = clients[(int)operatorType];

            // Avoid to fail because Windows issue
            if (dialect == ModelDialectRevision.Smb2002)
            {
                clientInfo.ClientGuid = Guid.NewGuid();
            }

            if (!clientInfo.IsInitialized)
            {
                InitializeClient(clientInfo, dialect);
            }

            if (operation == FileOperation.WRITE_DATA)
            {
                #region WRITE_DATA

                uint status = Smb2Status.STATUS_SUCCESS;

                Packet_Header header;
                CREATE_Response createResponse;
                Smb2CreateContextResponse[] serverCreateContexts;

                if (!clientInfo.IsOpened)
                {
                    status = clientInfo.Client.Create(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.File,
                        AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                        ShareAccess_Values.FILE_SHARE_READ | ShareAccess_Values.FILE_SHARE_WRITE | ShareAccess_Values.FILE_SHARE_DELETE,
                        originalClient.IsDirectory ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                        CreateDisposition_Values.FILE_OPEN_IF,
                        File_Attributes.NONE,
                        ImpersonationLevel_Values.Impersonation,
                        SecurityFlags_Values.NONE,
                        clientInfo.CreateContexts == null ? RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE : RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE,
                        clientInfo.CreateContexts,
                        out clientInfo.FileId,
                        out serverCreateContexts,
                        out header,
                        out createResponse);
                    Site.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, status, "Expect that creation succeeds.");
                }

                byte[] data = Encoding.ASCII.GetBytes("Write data to break READ caching.");
                ushort creditCharge = Smb2Utility.CalculateCreditCharge((uint)data.Length, ModelUtility.GetDialectRevision(dialect));

                clientInfo.LastOperationMessageId = clientInfo.MessageId;
                clientInfo.Client.WriteRequest(creditCharge, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId,
                    0, clientInfo.FileId, Channel_Values.CHANNEL_NONE, WRITE_Request_Flags_Values.None, new byte[0], data);
                clientInfo.MessageId += (ulong)creditCharge;

                #endregion
            }
            else if (operation == FileOperation.SIZE_CHANGED)
            {
                #region SIZE_CHANGED

                uint status = Smb2Status.STATUS_SUCCESS;

                Packet_Header header;
                CREATE_Response createResponse;
                Smb2CreateContextResponse[] serverCreateContexts;

                if (!clientInfo.IsOpened)
                {
                    status = clientInfo.Client.Create(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.File,
                        AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                        ShareAccess_Values.FILE_SHARE_READ | ShareAccess_Values.FILE_SHARE_WRITE | ShareAccess_Values.FILE_SHARE_DELETE,
                        originalClient.IsDirectory ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                        CreateDisposition_Values.FILE_OPEN,
                        File_Attributes.NONE,
                        ImpersonationLevel_Values.Impersonation,
                        SecurityFlags_Values.NONE,
                        clientInfo.CreateContexts == null ? RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE : RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE,
                        clientInfo.CreateContexts,
                        out clientInfo.FileId,
                        out serverCreateContexts,
                        out header,
                        out createResponse);
                    Site.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, status, "Expect that creation succeeds.");
                }

                FileEndOfFileInformation changeSizeInfo;
                changeSizeInfo.EndOfFile = 512;

                byte[] inputBuffer;
                inputBuffer = TypeMarshal.ToBytes<FileEndOfFileInformation>(changeSizeInfo);

                clientInfo.LastOperationMessageId = clientInfo.MessageId;
                clientInfo.Client.SetInfoRequest(
                    1,
                    1,
                    clientInfo.Flags,
                    clientInfo.MessageId++,
                    clientInfo.SessionId,
                    clientInfo.TreeId,
                    SET_INFO_Request_InfoType_Values.SMB2_0_INFO_FILE,
                    (byte)FileInformationClasses.FileEndOfFileInformation,
                    SET_INFO_Request_AdditionalInformation_Values.NONE,
                    clientInfo.FileId,
                    inputBuffer);

                #endregion
            }
            else if (operation == FileOperation.RANGE_LOCK)
            {
                #region RANGE_LOCK

                uint status = Smb2Status.STATUS_SUCCESS;

                Packet_Header header;
                CREATE_Response createResponse;
                Smb2CreateContextResponse[] serverCreateContexts;

                if (!clientInfo.IsOpened)
                {
                    status = clientInfo.Client.Create(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.File,
                        AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                        ShareAccess_Values.FILE_SHARE_READ | ShareAccess_Values.FILE_SHARE_WRITE | ShareAccess_Values.FILE_SHARE_DELETE,
                        originalClient.IsDirectory ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                        CreateDisposition_Values.FILE_OPEN,
                        File_Attributes.NONE,
                        ImpersonationLevel_Values.Impersonation,
                        SecurityFlags_Values.NONE,
                        clientInfo.CreateContexts == null ? RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE : RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE,
                        clientInfo.CreateContexts,
                        out clientInfo.FileId,
                        out serverCreateContexts,
                        out header,
                        out createResponse);
                    Site.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, status, "Expect that creation succeeds.");
                }

                clientInfo.Locks = new LOCK_ELEMENT[1];
                clientInfo.LockSequence = 0;
                clientInfo.Locks[0].Offset = 0;
                clientInfo.Locks[0].Length = (ulong)1 * 1024 / 2;
                clientInfo.Locks[0].Flags = LOCK_ELEMENT_Flags_Values.LOCKFLAG_SHARED_LOCK;

                clientInfo.LastOperationMessageId = clientInfo.MessageId;
                clientInfo.Client.LockRequest(
                    1,
                    1,
                    clientInfo.Flags,
                    clientInfo.MessageId++,
                    clientInfo.SessionId,
                    clientInfo.TreeId,
                    clientInfo.LockSequence++,
                    clientInfo.FileId,
                    clientInfo.Locks
                    );

                #endregion
            }
            else if (operation == FileOperation.OPEN_OVERWRITE)
            {
                #region OPEN_OVERWRITE
                if (clientInfo.IsOpened)
                {
                    clientInfo.Reset(operatorType == OperatorType.SecondClient);

                    InitializeClient(clientInfo, dialect);
                }

                clientInfo.LastOperationMessageId = clientInfo.MessageId;
                clientInfo.Client.CreateRequest(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.File,
                    AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                    ShareAccess_Values.FILE_SHARE_READ | ShareAccess_Values.FILE_SHARE_WRITE | ShareAccess_Values.FILE_SHARE_DELETE,
                    originalClient.IsDirectory ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                    CreateDisposition_Values.FILE_OVERWRITE,
                    File_Attributes.NONE,
                    ImpersonationLevel_Values.Impersonation,
                    SecurityFlags_Values.NONE,
                    clientInfo.CreateContexts == null ? RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE : RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE,
                    clientInfo.CreateContexts);

                #endregion
            }
            else if (operation == FileOperation.OPEN_WITHOUT_OVERWRITE)
            {
                #region OPEN_WITHOUT_OVERWRITE
                if (clientInfo.IsOpened)
                {
                    clientInfo.Reset(operatorType == OperatorType.SecondClient);

                    InitializeClient(clientInfo, dialect);
                }

                if (!clientInfo.IsOpened)
                {
                    clientInfo.LastOperationMessageId = clientInfo.MessageId;
                    clientInfo.Client.CreateRequest(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.File,
                        AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                        ShareAccess_Values.FILE_SHARE_READ | ShareAccess_Values.FILE_SHARE_WRITE | ShareAccess_Values.FILE_SHARE_DELETE,
                        originalClient.IsDirectory ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                        CreateDisposition_Values.FILE_OPEN,
                        File_Attributes.NONE,
                        ImpersonationLevel_Values.Impersonation,
                        SecurityFlags_Values.NONE,
                        clientInfo.CreateContexts == null ? RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE : RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE,
                        clientInfo.CreateContexts);
                }

                #endregion
            }
            else if (operation == FileOperation.OPEN_SHARING_VIOLATION)
            {
                #region OPEN_SHARING_VIOLATION
                if (clientInfo.IsOpened)
                {
                    clientInfo.Reset(operatorType == OperatorType.SecondClient);

                    InitializeClient(clientInfo, dialect);
                }

                if (!clientInfo.IsOpened)
                {
                    clientInfo.LastOperationMessageId = clientInfo.MessageId;
                    clientInfo.Client.CreateRequest(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.File,
                        AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                        ShareAccess_Values.FILE_SHARE_READ,
                        originalClient.IsDirectory ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                        CreateDisposition_Values.FILE_OPEN,
                        File_Attributes.NONE,
                        ImpersonationLevel_Values.Impersonation,
                        SecurityFlags_Values.NONE,
                        clientInfo.CreateContexts == null ? RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE : RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE,
                        clientInfo.CreateContexts);
                }
                #endregion
            }
            else if (operation == FileOperation.OPEN_SHARING_VIOLATION_WITH_OVERWRITE)
            {
                #region OPEN_SHARING_VIOLATION_WITH_OVERWRITE
                if (clientInfo.IsOpened)
                {
                    clientInfo.Reset(operatorType == OperatorType.SecondClient);

                    InitializeClient(clientInfo, dialect);
                }

                if (!clientInfo.IsOpened)
                {
                    clientInfo.LastOperationMessageId = clientInfo.MessageId;
                    clientInfo.Client.CreateRequest(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.File,
                        AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                        ShareAccess_Values.FILE_SHARE_READ,
                        originalClient.IsDirectory ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                        CreateDisposition_Values.FILE_OVERWRITE,
                        File_Attributes.NONE,
                        ImpersonationLevel_Values.Impersonation,
                        SecurityFlags_Values.NONE,
                        clientInfo.CreateContexts == null ? RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE : RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE,
                        clientInfo.CreateContexts);
                }

                #endregion
            }
            else if (operation == FileOperation.DELETED)
            {
                #region DELETED
                if (clientInfo.IsOpened)
                {
                    clientInfo.Reset(operatorType == OperatorType.SecondClient);

                    InitializeClient(clientInfo, dialect);
                }

                uint status = Smb2Status.STATUS_SUCCESS;

                Packet_Header header;
                CREATE_Response createResponse;
                Smb2CreateContextResponse[] serverCreateContexts;

                if (!clientInfo.IsOpened)
                {
                    clientInfo.Client.Create(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.File,
                        AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                        ShareAccess_Values.FILE_SHARE_READ | ShareAccess_Values.FILE_SHARE_WRITE | ShareAccess_Values.FILE_SHARE_DELETE,
                        (originalClient.IsDirectory ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE) | CreateOptions_Values.FILE_DELETE_ON_CLOSE,
                        CreateDisposition_Values.FILE_OPEN,
                        File_Attributes.NONE,
                        ImpersonationLevel_Values.Impersonation,
                        SecurityFlags_Values.NONE,
                        clientInfo.CreateContexts == null ? RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE : RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE,
                        clientInfo.CreateContexts,
                        out clientInfo.FileId,
                        out serverCreateContexts,
                        out header,
                        out createResponse);
                    Site.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, status, "Expect that creation succeeds.");
                }

                FileDispositionInformation deleteInfo;
                deleteInfo.DeletePending = 1;

                byte[] inputBuffer;
                inputBuffer = TypeMarshal.ToBytes<FileDispositionInformation>(deleteInfo);

                clientInfo.LastOperationMessageId = clientInfo.MessageId;
                clientInfo.Client.SetInfoRequest(
                    1,
                    1,
                    clientInfo.Flags,
                    clientInfo.MessageId++,
                    clientInfo.SessionId,
                    clientInfo.TreeId,
                    SET_INFO_Request_InfoType_Values.SMB2_0_INFO_FILE,
                    (byte)FileInformationClasses.FileDispositionInformation,
                    SET_INFO_Request_AdditionalInformation_Values.NONE,
                    clientInfo.FileId,
                    inputBuffer);
                #endregion
            }
            else if (operation == FileOperation.RENAMEED)
            {
                #region RENAMEED
                if (clientInfo.IsOpened)
                {
                    clientInfo.Reset(operatorType == OperatorType.SecondClient);

                    InitializeClient(clientInfo, dialect);
                }

                uint status = Smb2Status.STATUS_SUCCESS;

                Packet_Header header;
                CREATE_Response createResponse;
                Smb2CreateContextResponse[] serverCreateContexts;

                if (!clientInfo.IsOpened)
                {
                    status = clientInfo.Client.Create(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.File,
                        AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                        ShareAccess_Values.FILE_SHARE_READ | ShareAccess_Values.FILE_SHARE_WRITE | ShareAccess_Values.FILE_SHARE_DELETE,
                        originalClient.IsDirectory ? CreateOptions_Values.FILE_DIRECTORY_FILE : CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                        CreateDisposition_Values.FILE_OPEN,
                        File_Attributes.NONE,
                        ImpersonationLevel_Values.Impersonation,
                        SecurityFlags_Values.NONE,
                        clientInfo.CreateContexts == null ? RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE : RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE,
                        clientInfo.CreateContexts,
                        out clientInfo.FileId,
                        out serverCreateContexts,
                        out header,
                        out createResponse);
                    Site.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, status, "Expect that creation succeeds.");
                }

                string newFileName = originalClient.ParentDirectory + "\\" + Guid.NewGuid().ToString();
                FileRenameInformation info = new FileRenameInformation();
                info.ReplaceIfExists = 1;
                info.FileName = ConvertStringToByteArray(newFileName);
                info.FileNameLength = (uint)info.FileName.Length;
                info.RootDirectory = FileRenameInformation_RootDirectory_Values.V1;
                info.Reserved = new byte[7];

                byte[] inputBuffer;
                inputBuffer = TypeMarshal.ToBytes<FileRenameInformation>(info);

                clientInfo.LastOperationMessageId = clientInfo.MessageId;
                clientInfo.Client.SetInfoRequest(
                    1,
                    1,
                    clientInfo.Flags,
                    clientInfo.MessageId++,
                    clientInfo.SessionId,
                    clientInfo.TreeId,
                    SET_INFO_Request_InfoType_Values.SMB2_0_INFO_FILE,
                    (byte)FileInformationClasses.FileRenameInformation,
                    SET_INFO_Request_AdditionalInformation_Values.NONE,
                    clientInfo.FileId,
                    inputBuffer);

                originalClient.File = newFileName;
                #endregion
            }
            else if (operation == FileOperation.PARENT_DIR_RENAMED)
            {
                #region PARENT_DIR_RENAMED
                if (clientInfo.IsOpened)
                {
                    clientInfo.Reset(operatorType == OperatorType.SecondClient);

                    InitializeClient(clientInfo, dialect);
                }

                uint status = Smb2Status.STATUS_SUCCESS;

                Packet_Header header;
                CREATE_Response createResponse;
                Smb2CreateContextResponse[] serverCreateContexts;

                if (!clientInfo.IsOpened)
                {
                    status = clientInfo.Client.Create(1, 64, clientInfo.Flags, clientInfo.MessageId++, clientInfo.SessionId, clientInfo.TreeId, originalClient.ParentDirectory,
                        AccessMask.GENERIC_READ | AccessMask.GENERIC_WRITE | AccessMask.DELETE,
                        ShareAccess_Values.FILE_SHARE_READ | ShareAccess_Values.FILE_SHARE_WRITE | ShareAccess_Values.FILE_SHARE_DELETE,
                        CreateOptions_Values.FILE_DIRECTORY_FILE,
                        CreateDisposition_Values.FILE_OPEN,
                        File_Attributes.NONE,
                        ImpersonationLevel_Values.Impersonation,
                        SecurityFlags_Values.NONE,
                        RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE,
                        null,
                        out clientInfo.FileId,
                        out serverCreateContexts,
                        out header,
                        out createResponse);
                    Site.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, status, "Expect that creation succeeds.");
                }

                string newFileName = "LeasingDir_" + Guid.NewGuid().ToString();
                FileRenameInformation info = new FileRenameInformation();
                info.ReplaceIfExists = 0;
                info.FileName = ConvertStringToByteArray(newFileName);
                info.FileNameLength = (uint)info.FileName.Length;
                info.RootDirectory = FileRenameInformation_RootDirectory_Values.V1;
                info.Reserved = new byte[7];

                byte[] inputBuffer;
                inputBuffer = TypeMarshal.ToBytes<FileRenameInformation>(info);

                clientInfo.LastOperationMessageId = clientInfo.MessageId;
                clientInfo.Client.SetInfoRequest(
                    1,
                    1,
                    clientInfo.Flags,
                    clientInfo.MessageId++,
                    clientInfo.SessionId,
                    clientInfo.TreeId,
                    SET_INFO_Request_InfoType_Values.SMB2_0_INFO_FILE,
                    (byte)FileInformationClasses.FileRenameInformation,
                    SET_INFO_Request_AdditionalInformation_Values.NONE,
                    clientInfo.FileId,
                    inputBuffer);
                // Does not need to update these two fields File and ParentDirectory in orginal client because the operation will fail.
                #endregion
            }

            lastOperation = new BreakOperation(operation, operatorType);
        }
 private void OnOperationAdded(FileOperation operation)
 {
     Application.Current.Dispatcher.BeginInvoke((Action)( ()=>
         _operationList.Add(new FileOperationViewmodel(operation)))
         , null);
 }
示例#35
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="FileOperationResult" /> class.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="opperation">The opperation.</param>
 /// <param name="succeeded">if set to <c>true</c> [succeeded].</param>
 public FileOperationResult(string fileName, FileOperation opperation, bool succeeded)
 {
     FileName = fileName;
     FileOperation = opperation;
     Succeeded = succeeded;
 }
示例#36
0
 public IActionResult Post(Operator data)
 {
     data.Id     = Guid.NewGuid().ToString();
     data.ImgUrl = FileOperation.FileImg(data.ImgFile, data.Id, rootPath, Path(data.ParentId));
     return(Json(_col.Insert(data)));
 }
 public ModelFileOperationRequest(
     FileOperation operation,
     OperatorType operatorType,
     ModelDialectRevision dialect)
     : base(0)
 {
     this.Operation = operation;
     this.OptorType = operatorType;
     this.Dialect = dialect;
 }
示例#38
0
文件: Menu.cs 项目: oleeq2/ToDo
        public bool getPathMenu(FileOperation rw,out string path)
        {
            bool ret = true;
            bool flag = false;
            path = String.Empty;
            do
            {
                string str = _getPath();
                if (rw == FileOperation.Write)
                {
                    if (File.Exists(str))
                    {
                        bool ans = _askUser("File exists override? ");
                        if (!ans)
                        {
                            flag = true;
                            continue;
                        }
                        else
                        {
                            path = str;
                        }
                    }
                    path = str;
                }
                path = str;
            }while(flag);

            return ret;
        }
示例#39
0
        private static void DirectoryOperation(string sourceDirectory, string destinationDirectory, bool overwriteExistingFiles, bool forceWritable, FileOperation operation)
        {
            if ((sourceDirectory == null) || (sourceDirectory.Trim() == string.Empty))
            {
                throw new ArgumentNullException("sourceDirectory");
            }
            if ((destinationDirectory == null) || (destinationDirectory.Trim() == string.Empty))
            {
                throw new ArgumentNullException("destinationDirectory");
            }
            if (!Directory.Exists(sourceDirectory))
            {
                throw new DirectoryNotFoundException(sourceDirectory);
            }
            if (!Directory.Exists(destinationDirectory))
            {
                if (operation == FileOperation.Move)
                {
                    Directory.Move(sourceDirectory, destinationDirectory);
                    return;
                }
                if (operation == FileOperation.Copy)
                {
                    Directory.CreateDirectory(destinationDirectory);
                }
            }
            foreach (string str2 in Directory.GetFiles(sourceDirectory))
            {
                FileAttributes attributes = File.GetAttributes(str2);
                int num = ((int)attributes) & 2;
                int num2 = ((int)attributes) & 4;
                if ((num <= 0) && (num2 <= 0))
                {
                    string fileName = str2.Substring(str2.LastIndexOf(@"\") + 1);
                    string path = destinationDirectory + @"\" + fileName;
                    bool flag = false;
                    if (File.Exists(path))
                    {
                        if (overwriteExistingFiles)
                        {
                            SetFileReadOnly(path, false);
                            if (operation == FileOperation.Move)
                            {
                                File.Delete(path);
                            }
                        }
                        else if (operation == FileOperation.Move)
                        {
                            SetFileReadOnly(fileName, false);
                            File.Delete(fileName);
                            flag = true;
                        }
                    }
                    switch (operation)
                    {
                        case FileOperation.Copy:
                            File.Copy(str2, path, overwriteExistingFiles);
                            if (forceWritable)
                            {
                                SetFileReadOnly(destinationDirectory + @"\" + fileName, false);
                            }
                            break;

                        case FileOperation.Move:
                            if (!flag)
                            {
                                File.Move(str2, path);
                            }
                            break;
                    }
                }
            }
            foreach (string str in Directory.GetDirectories(sourceDirectory))
            {
                string str5 = str.Substring(str.LastIndexOf(@"\") + 1);
                DirectoryOperation(str, destinationDirectory + @"\" + str5, overwriteExistingFiles, forceWritable, operation);
                if ((operation == FileOperation.Copy) && forceWritable)
                {
                    SetFileReadOnly(destinationDirectory + @"\" + str5, false);
                }
            }
            if (operation == FileOperation.Move)
            {
                SetFileReadOnly(sourceDirectory, false);
                Directory.Delete(sourceDirectory);
            }
        }
示例#40
0
 private static void UpdateRemoteIndex(file file, FileOperation op)
 {
 }
示例#41
0
        private void StartBtn_Click(object sender, EventArgs e)
        {
            //清除列表项
            WarmListView.Items.Clear();
            DateTime SDTP = StartDTPicker.Value;
            DateTime EDTP = EndDTPicker.Value;
            int      syear, smonth, sday, shour, sminute, eyear, emonth, eday, ehour, eminute;

            syear = SDTP.Year; smonth = SDTP.Month; sday = SDTP.Day;
            eyear = EDTP.Year; emonth = EDTP.Month; eday = EDTP.Day;
            string StrSHour   = sHourCb.Text;
            string StrSMinute = sMinitueCb.Text;
            string StrEHour   = eHourCB.Text;
            string StrEMinute = eMinitueCB.Text;

            if ("".Equals(StrSHour) || "".Equals(StrSMinute) || "".Equals(StrEHour) || "".Equals(StrEMinute))
            {
                MessageBox.Show("開始時間與結束時間的小時與分針不能為空!");
                return;
            }
            try
            {
                shour   = Convert.ToInt32(StrSHour);
                sminute = Convert.ToInt32(StrSMinute);
                ehour   = Convert.ToInt32(StrEHour);
                eminute = Convert.ToInt32(StrEMinute);
            }
            catch (Exception)
            {
                MessageBox.Show("開始時間與結束時間的小時與分針格式有誤!");
                return;
            }
            DateTime SDT, EDT;

            try
            {
                SDT = new DateTime(syear, smonth, sday, shour, sminute, 0);
                EDT = new DateTime(eyear, emonth, eday, ehour, eminute, 59);
            }catch (Exception)
            {
                MessageBox.Show("開始時間或結束時間格式有誤!");
                return;
            }
            if (DateTime.Compare(EDT, SDT) <= 0)
            {
                MessageBox.Show("結束時間要大於開始時間!");
                return;
            }
            //时间参数没有问题后,开始从原始的警报文件中导出数据
            string StrDir      = FileOperation.WarmMsg;
            string StrFileName = StrDir + "\\" + FileOperation.WarmName;

            //得到源文件中的数据信息

            if (null == StrFileName || "".Equals(StrFileName))
            {
                MessageBox.Show("源文件路徑出錯!");
                return;
            }
            CommonCollection.LogWarms = FileOperation.GetWarmData(StrFileName);
            //将当前的数据信息加到集合中去
            try
            {
                foreach (WarmInfo wm in CommonCollection.WarmInfors)
                {
                    CommonCollection.LogWarms.Add(wm);
                }
            }catch (Exception)
            {
            }
            if (null == CommonCollection.LogWarms)
            {
                MessageBox.Show("獲取警報資訊失敗!");
                return;
            }
            if (CommonCollection.LogWarms.Count <= 0)
            {
                MessageBox.Show("獲取警報訊息為空!");
                return;
            }
            //从全部的警报资讯信息中取出时间段中的警报资讯
            WarmListView.Items.Clear();
            foreach (WarmInfo wm in CommonCollection.LogWarms)
            {
                if (null == wm)
                {
                    continue;
                }
                // 判断警报产生时间是否在范围中
                if (DateTime.Compare(SDT, wm.AlarmTime) > 0)
                {
                    continue;
                }
                if (DateTime.Compare(EDT, wm.AlarmTime) <= 0)
                {
                    continue;
                }
                //当前时间满足条件
                //参考点信息
                string StrRouterInfo = wm.RD[0].ToString("X2") + wm.RD[1].ToString("X2");
                string StrRouterName = wm.RDName;
                if (null == StrRouterName || "".Equals(StrRouterName))
                {
                    StrRouterInfo = "參考點:" + StrRouterInfo;
                }
                else
                {
                    StrRouterInfo = "參考點:" + StrRouterName + "(" + StrRouterInfo + ")";
                }
                //區域信息
                string StrAreaInfo = wm.AD[0].ToString("X2") + wm.AD[1].ToString("X2");
                string StrAreaName = wm.AreaName;
                if (null == StrAreaName || "".Equals(StrAreaName))
                {
                    StrAreaInfo = "所在區域:" + StrAreaInfo;
                }
                else
                {
                    StrAreaInfo = "所在區域:" + StrAreaName + "(" + StrAreaInfo + ")";
                }
                //警报产生时间
                string StrAlarmTime = "警報產生時間:" + wm.AlarmTime.ToString();
                if (DateTime.Compare(wm.AlarmTime, wm.ClearAlarmTime) != 0)
                {
                    StrAlarmTime = StrAlarmTime + " 警報處理時間:" + wm.ClearAlarmTime.ToString();
                }
                else
                {
                    StrAlarmTime = StrAlarmTime + " 警報處理時間:    未處理   ";
                }
                string StrHandler = "是否處理:" + wm.isHandler.ToString();
                string StrClear   = "是否清除:" + wm.isClear.ToString();
                string StrLog     = "";
                string ClassName  = wm.GetType().Name;
                switch (CurWarmType)
                {
                case SpeceilAlarm.BatteryLow:
                    if ("BattLow".Equals(ClassName))
                    {
                        string StrTagInfo = ((BattLow)wm).TD[0].ToString("X2") + ((BattLow)wm).TD[1].ToString("X2");
                        string StrTagName = ((BattLow)wm).TagName;
                        //卡片信息
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        //當前的電量
                        string StrBatt = "當前的電量:" + ((BattLow)wm).Batt.ToString() + "(" + ((BattLow)wm).BasicBatt.ToString() + ")" + "%";
                        StrLog = "電量不足###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrBatt + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    break;

                case SpeceilAlarm.PersonHelp:
                    if ("PersonHelp".Equals(ClassName))
                    {
                        string StrTagInfo = ((PersonHelp)wm).TD[0].ToString("X2") + ((PersonHelp)wm).TD[1].ToString("X2");
                        string StrTagName = ((PersonHelp)wm).TagName;
                        //卡片信息
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        StrLog = "人員求助###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    break;

                case SpeceilAlarm.AreaControl:
                    if ("AreaAdmin".Equals(ClassName))
                    {
                        string StrTagInfo = ((AreaAdmin)wm).TD[0].ToString("X2") + ((AreaAdmin)wm).TD[1].ToString("X2");
                        string StrTagName = ((AreaAdmin)wm).TagName;
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        //卡片当前的区域状况
                        string StrTagType = "卡片權限:";
                        if (null != ((AreaAdmin)wm).TagAreaSt)
                        {
                            StrTagType = StrTagType + ((AreaAdmin)wm).TagAreaSt.GetAreasStr();
                        }
                        StrLog = "區域管制警報###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    break;

                case SpeceilAlarm.Resid:
                    if ("PersonRes".Equals(ClassName))
                    {
                        string StrTagInfo = ((PersonRes)wm).TD[0].ToString("X2") + ((PersonRes)wm).TD[1].ToString("X2");
                        string StrTagName = ((PersonRes)wm).TagName;
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        //人员滞留时间
                        string StrResTime = "人員未移動時間:" + ((PersonRes)wm).ResTime.ToString() + "(" + ((PersonRes)wm).BasicResTime + ") s";
                        StrLog = "人員未移動警報###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrResTime + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    break;

                case SpeceilAlarm.TagDis:
                    if ("TagDis".Equals(ClassName))
                    {
                        string StrTagInfo = ((TagDis)wm).TD[0].ToString("X2") + ((TagDis)wm).TD[1].ToString("X2");
                        string StrTagName = ((TagDis)wm).TagName;
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        //卡片的休眠时间
                        string StrSleepTime = "卡片的休眠時間:" + (((TagDis)wm).SleepTime / 10).ToString() + " s";
                        StrLog = "卡片異常警報###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrSleepTime + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    break;

                case SpeceilAlarm.ReferDis:
                    if ("ReferDis".Equals(ClassName))
                    {
                        //参考点的休眠时间

                        string StrRouterSp = "參考點上報间隔时间:" + ((((ReferDis)wm).SleepTime <= 0)?"***" : ((ReferDis)wm).SleepTime.ToString() + " s");
                        StrLog = "參考點異常警報###" + StrRouterInfo + " " + StrAreaInfo + " " + StrRouterSp + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    break;

                case SpeceilAlarm.NodeDis:
                    if ("NodeDis".Equals(ClassName))
                    {
                        string StrNodeSp = "數據節點上報間隔時間:" + ((((NodeDis)wm).SleepTime <= 0) ? "***" : ((NodeDis)wm).SleepTime.ToString() + " s");
                        StrLog = "數據節點異常警報###" + StrRouterInfo + " " + StrAreaInfo + " " + StrNodeSp + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    break;

                case SpeceilAlarm.UnKnown:
                default:
                    if ("BattLow".Equals(ClassName))
                    {
                        string StrTagInfo = ((BattLow)wm).TD[0].ToString("X2") + ((BattLow)wm).TD[1].ToString("X2");
                        string StrTagName = ((BattLow)wm).TagName;
                        //卡片信息
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        //當前的電量
                        string StrBatt = "當前的電量:" + ((BattLow)wm).Batt.ToString() + "(" + ((BattLow)wm).BasicBatt.ToString() + ")" + "%";
                        StrLog = "電量不足###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrBatt + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    else if ("PersonHelp".Equals(ClassName))
                    {
                        string StrTagInfo = ((PersonHelp)wm).TD[0].ToString("X2") + ((PersonHelp)wm).TD[1].ToString("X2");
                        string StrTagName = ((PersonHelp)wm).TagName;
                        //卡片信息
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        StrLog = "人員求助###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    else if ("AreaAdmin".Equals(ClassName))
                    {
                        string StrTagInfo = ((AreaAdmin)wm).TD[0].ToString("X2") + ((AreaAdmin)wm).TD[1].ToString("X2");
                        string StrTagName = ((AreaAdmin)wm).TagName;
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        //卡片当前的区域状况
                        string StrTagType = "卡片權限:";
                        if (null != ((AreaAdmin)wm).TagAreaSt)
                        {
                            StrTagType = StrTagType + ((AreaAdmin)wm).TagAreaSt.GetAreasStr();
                        }
                        StrLog = "區域管制警報###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    else if ("PersonRes".Equals(ClassName))
                    {
                        string StrTagInfo = ((PersonRes)wm).TD[0].ToString("X2") + ((PersonRes)wm).TD[1].ToString("X2");
                        string StrTagName = ((PersonRes)wm).TagName;
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        //人员滞留时间
                        string StrResTime = "人員未移動時間:" + ((PersonRes)wm).ResTime.ToString() + "(" + ((PersonRes)wm).BasicResTime + ") s";
                        StrLog = "人員未移動警報###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrResTime + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    else if ("TagDis".Equals(ClassName))
                    {
                        string StrTagInfo = ((TagDis)wm).TD[0].ToString("X2") + ((TagDis)wm).TD[1].ToString("X2");
                        string StrTagName = ((TagDis)wm).TagName;
                        if (null == StrTagName || "".Equals(StrTagName))
                        {
                            StrTagInfo = "卡片:" + StrTagInfo;
                        }
                        else
                        {
                            StrTagInfo = "卡片:" + StrTagName + "(" + StrTagInfo + ")";
                        }
                        //卡片的休眠时间
                        string StrSleepTime = "卡片的休眠時間:" + ((TagDis)wm).SleepTime.ToString();
                        StrLog = "卡片異常警報###" + StrTagInfo + " " + StrRouterInfo + " " + StrAreaInfo + " " + StrSleepTime + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    else if ("ReferDis".Equals(ClassName))
                    {
                        //参考点的休眠时间
                        string StrRouterSp = "參考點上報间隔时间:" + ((((ReferDis)wm).SleepTime <= 0) ? "***" : ((ReferDis)wm).SleepTime.ToString() + " s");
                        StrLog = "參考點異常警報###" + StrRouterInfo + " " + StrAreaInfo + " " + StrRouterSp + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    else if ("NodeDis".Equals(ClassName))
                    {
                        string StrNodeSp = "數據節點上報間隔時間:" + ((((NodeDis)wm).SleepTime <= 0) ? "***" : ((NodeDis)wm).SleepTime.ToString() + " s");
                        StrLog = "數據節點異常警報###" + StrRouterInfo + " " + StrAreaInfo + " " + StrNodeSp + " " + StrAlarmTime + " " + StrHandler + " " + StrClear;
                    }
                    break;
                }
                if (null != StrLog && !"".Equals(StrLog))
                {
                    WarmListView.Items.Add(StrLog);
                }
            }
            label8.Text = "當前記錄數:" + WarmListView.Items.Count + "條";
            if (WarmListView.Items.Count > 0)
            {
                AlarmMsgOutBtn.Enabled = true;
            }
        }
		public MaterialFileOeprationInfo(Material m, FileOperation op)
		{
			material = m;
			operation = op;
		}
示例#43
0
 public FrmNotePad()
 {
     InitializeComponent();
     fileOperation  = new FileOperation();
     txtEditor.Font = new Font("Consolas", 12, FontStyle.Regular);
 }
示例#44
0
 public QueueItem(FileSystemItem fileSystemItem, FileOperation fileOperation, object payload = null)
 {
     FileSystemItem = fileSystemItem;
     Operation = fileOperation;
     Payload = payload;
 }
示例#45
0
        /// <summary>
        /// Perform action on the file
        /// </summary>
        /// <param name="operation">what to do?</param>
        /// <param name="itemTag">File info</param>
        private void handleFileOperation(FileOperation operation, FileInfo fileInfo)
        {
            switch (operation)
            {
                case FileOperation.Open:
                    SelectedFile = fileInfo.FullName;
                    if (EvtFileOpen != null)
                    {
                        EvtFileOpen.BeginInvoke(this, new EventArgs(), null, null);
                    }

                    break;

                case FileOperation.Delete:
                    handleDeleteFile(fileInfo);
                    break;
            }
        }
示例#46
0
 private bool ConfirmCommand(FileOperation type, bool isPlural)
 {
     var title = Resx.ResourceManager.GetString(type.ToString());
     var message = Resx.ResourceManager.GetString(string.Format(isPlural ? "{0}ConfirmationPlural" : "{0}ConfirmationSingular", type));
     return WindowManager.Confirm(title, message);
 }
    private VirtualFolderInfo PerformFolderOperation(string virtualFolderPath, string destinationPath, FileOperation operation)
    {
      if (virtualFolderPath == null) throw new ArgumentNullException("virtualFolderPath");
      if (destinationPath == null) throw new ArgumentNullException("destinationPath");

      //get folder info for source and destination, thus validating the scope of both
      string absoluteSource;
      var sourceFolder = GetFolderInfoInternal(virtualFolderPath, true, out absoluteSource);
      string absoluteDestination;
      GetFolderInfoInternal(destinationPath, false, out absoluteDestination);

      string operationName = operation == FileOperation.Move ? "move" : "copy";

      if (sourceFolder.IsRootFolder)
      {
        string msg = String.Format("Cannot {0} root folder (attempted destination: '{1}').", operationName, destinationPath);
        VfsLog.Debug(msg);
        throw new ResourceAccessException(msg);
      }

      if (String.Equals(absoluteSource, absoluteDestination, StringComparison.InvariantCultureIgnoreCase))
      {
        string msg = String.Format("Cannot {0} folder to '{1}' - source and destination are the same.", operationName, destinationPath);
        VfsLog.Debug(msg);
        throw new ResourceAccessException(msg);
      }

      var sourceDir = new DirectoryInfo(absoluteSource);
      if (sourceDir.IsParentOf(absoluteDestination))
      {
        string msg = String.Format("Cannot {0} folder '{1}' to '{2}' - destination folder is a child of the folder.", operationName, virtualFolderPath, destinationPath);
        VfsLog.Debug(msg);
        throw new ResourceAccessException(msg);
      }

      if (Directory.Exists(absoluteDestination))
      {
        string msg = "Cannot {0} folder '{1}' to '{2}' - the destination folder already exists.";
        msg = String.Format(msg, operationName, virtualFolderPath, destinationPath);
        VfsLog.Debug(msg);
        throw new ResourceOverwriteException(msg);
      }


      try
      {
        switch(operation)
        {
          case FileOperation.Move:
            Directory.Move(absoluteSource, absoluteDestination);
            break;
          case FileOperation.Copy:
            PathUtil.CopyDirectory(absoluteSource, absoluteDestination, false);
            break;
          default:
            VfsLog.Fatal("Unsupported file operation received: {0}", operation);
            throw new ArgumentOutOfRangeException("operation");
        }

        return GetFolderInfo(absoluteDestination);
      }
      catch (Exception e)
      {
        string msg = String.Format("An error occurred while trying to {0} directory '{1}' to '{2}'.",
                                          operationName, virtualFolderPath, destinationPath);
        VfsLog.Warn(e, msg);
        throw new ResourceAccessException(msg, e);
      }
    }
示例#48
0
 public IActionResult Put(string id, Operator data)
 {
     data.ImgUrl = FileOperation.FileImg(data.ImgFile, data.Id, rootPath, Path(data.ParentId));
     return(Json(_col.UpData(id, data)));
 }
        /// <summary>
        /// Replaces the text.
        /// </summary>
        /// <param name="fileOperation">The file operation.</param>
        /// <param name="projectService">The project service.</param>
        /// <param name="projectItemService">The project item service.</param>
        private void ReplaceText(
            FileOperation fileOperation,
            IProjectService projectService,
            IProjectItemService projectItemService)
        {
            if (projectService == null)
            {
                return;
            }

            if (projectItemService == null)
            {
                return;
            }

            string to = fileOperation.To.Replace("$rootnamespace$", projectService.Name);

            to = to.Replace("$CoreProject$", this.settingsService.CoreProjectSuffix.Substring(1));
            to = to.Replace("$FormsProject$", this.settingsService.XamarinFormsProjectSuffix.Substring(1));
            to = to.Replace("$iOSProject$", this.settingsService.iOSProjectSuffix.Substring(1));
            to = to.Replace("$DroidProject$", this.settingsService.DroidProjectSuffix.Substring(1));
            to = to.Replace("$WindosPhonedProject$", this.settingsService.WindowsPhoneProjectSuffix.Substring(1));
            to = to.Replace("$WindosUniversalProject$", this.settingsService.WindowsUniversalProjectSuffix.Substring(1));
            to = to.Replace("$WpfProject$", this.settingsService.WpfProjectSuffix.Substring(1));

            string from = fileOperation.From;

            TraceService.WriteDebugLine("from=" + @from + " to" + to);

            if (@from != to)
            {
                projectItemService.ReplaceText(fileOperation.From, to);
                TraceService.WriteDebugLine("**Replaced**");
            }
            else
            {
                TraceService.WriteDebugLine("No need to replace!");
            }
        }
示例#50
0
 public uint CopyCallback(IntPtr parentWindow, FileOperation fileOperation, uint flags, string source, uint sourceAttributes, string destination, uint destinationAttributes)
 {
     Contract.Requires(source != null);
     return(default(uint));
 }
 /// <summary>
 /// Updates the property.
 /// </summary>
 /// <param name="fileOperation">The file operation.</param>
 /// <param name="projectItemService">The project item service.</param>
 private void UpdateProperty(
     FileOperation fileOperation, 
     IProjectItemService projectItemService)
 {
     if (projectItemService.ProjectItem != null)
     {
         projectItemService.ProjectItem.Properties.Item(fileOperation.From).Value = fileOperation.To;
         TraceService.WriteDebugLine("**Properties Updates**");
     }
 }
示例#52
0
        /// <summary>
        /// 记录导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AlarmMsgOutBtn_Click(object sender, EventArgs e)
        {
            if (WarmListView.Items.Count <= 0)
            {
                MessageBox.Show("請先搜索出需要的警報信息!");
                return;
            }
            SaveFileDialog MyDialog = new SaveFileDialog();

            MyDialog.Title = "選擇警報文件保存位置";
            if (txtRB.Checked)
            {
                MyDialog.Filter = "所有文本文件|*.txt";
            }
            else if (xlsRB.Checked)
            {
                MyDialog.Filter = "所有文本文件|*.xls";
            }
            if (MyDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string StrFilePath = MyDialog.FileName;

            if (txtRB.Checked)
            {
                if (!FileOperation.CreateDirFile(StrFilePath))
                {
                    return;
                }
                FileOperation.ClearFileContent(StrFilePath);
                foreach (string str in WarmListView.Items)
                {
                    FileOperation.WriteDataFile(StrFilePath, str + "\r\n");
                }
            }
            else if (xlsRB.Checked)
            {
                //导入为xls格式
                NpoiLib MyNpoiLib = new NpoiLib("AlarmMessage");
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 0, "警報類型");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 0, 3000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 1, "卡片信息");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 1, 6000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 2, "參考點信息");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 2, 8000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 3, "區域信息");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 3, 8000);

                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 4, "當前電量");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 4, 3000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 5, "休眠時間");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 5, 3000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 6, "人員未移動時間");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 6, 3000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 7, "參考點上報間隔時間");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 7, 3000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 8, "數據節點上報間隔時間");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 8, 3000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 9, "警報產生時間");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 9, 5000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 10, "警報消除時間");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 10, 5000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 11, "是否處理");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 11, 2000);
                MyNpoiLib.writeToCell(MyNpoiLib.sheet1, 0, 12, "是否清除");
                MyNpoiLib.SetColumnWidth(MyNpoiLib.sheet1, 12, 2000);

                if (null == CommonCollection.LogWarms)
                {
                    MessageBox.Show("對不起,導出文件失敗!"); return;
                }
                DateTime SDTP = StartDTPicker.Value; DateTime EDTP = EndDTPicker.Value;
                int      syear, smonth, sday, shour, sminute, eyear, emonth, eday, ehour, eminute;
                syear = SDTP.Year; smonth = SDTP.Month; sday = SDTP.Day; eyear = EDTP.Year; emonth = EDTP.Month; eday = EDTP.Day;
                string StrSHour = sHourCb.Text; string StrSMinute = sMinitueCb.Text;
                string StrEHour = eHourCB.Text; string StrEMinute = eMinitueCB.Text;
                try
                { shour = Convert.ToInt32(StrSHour); sminute = Convert.ToInt32(StrSMinute); ehour = Convert.ToInt32(StrEHour); eminute = Convert.ToInt32(StrEMinute); }
                catch (Exception) { MessageBox.Show("開始時間與結束時間的小時與分針格式有誤!"); return; }
                DateTime SDT, EDT;
                try
                { SDT = new DateTime(syear, smonth, sday, shour, sminute, 0); EDT = new DateTime(eyear, emonth, eday, ehour, eminute, 59); }
                catch (Exception)
                { MessageBox.Show("開始時間或結束時間格式有誤!"); return; }
                int index = 1;
                foreach (WarmInfo wm in CommonCollection.LogWarms)
                {
                    if (null == wm)
                    {
                        continue;
                    }
                    if (DateTime.Compare(SDT, wm.AlarmTime) > 0)
                    {
                        continue;
                    }
                    if (DateTime.Compare(EDT, wm.AlarmTime) < 0)
                    {
                        continue;
                    }
                    //参考点信息
                    string StrRouterInfo = wm.RD[0].ToString("X2") + wm.RD[1].ToString("X2");
                    string StrRouterName = wm.RDName;
                    if (null != StrRouterName && !"".Equals(StrRouterName))
                    {
                        StrRouterInfo = StrRouterName + "(" + StrRouterInfo + ")";
                    }
                    //區域信息
                    string StrAreaInfo = wm.AD[0].ToString("X2") + wm.AD[1].ToString("X2");
                    string StrAreaName = wm.AreaName;
                    if (null != StrAreaName && !"".Equals(StrAreaName))
                    {
                        StrAreaInfo = StrAreaName + "(" + StrAreaInfo + ")";
                    }
                    string StrClassName = wm.GetType().Name;
                    string StrWarmType  = "";
                    switch (CurWarmType)
                    {
                    case SpeceilAlarm.BatteryLow:
                        if ("BattLow".Equals(StrClassName))
                        {
                            StrWarmType = "低電量警報";
                            string StrTagInfo = ((BattLow)wm).TD[0].ToString("X2") + ((BattLow)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((BattLow)wm).TagName && !"".Equals(((BattLow)wm).TagName))
                            {
                                StrTagInfo = ((BattLow)wm).TagName + "(" + StrTagInfo + ")";
                            }
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 1, StrTagInfo);
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 4, ((BattLow)wm).Batt + "(" + ((BattLow)wm).BasicBatt + ") %");
                            break;
                        }
                        else
                        {
                            continue;
                        }

                    case SpeceilAlarm.PersonHelp:
                        if ("PersonHelp".Equals(StrClassName))
                        {
                            StrWarmType = "人員求救警報";
                            string StrTagInfo = ((PersonHelp)wm).TD[0].ToString("X2") + ((PersonHelp)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((PersonHelp)wm).TagName && !"".Equals(((PersonHelp)wm).TagName))
                            {
                                StrTagInfo = ((PersonHelp)wm).TagName + "(" + StrTagInfo + ")";
                            }
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 1, StrTagInfo);
                            break;
                        }
                        else
                        {
                            continue;
                        }

                    case SpeceilAlarm.AreaControl:
                        if ("AreaAdmin".Equals(StrClassName))
                        {
                            StrWarmType = "區域管制警報";
                            string StrTagInfo = ((AreaAdmin)wm).TD[0].ToString("X2") + ((AreaAdmin)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((AreaAdmin)wm).TagName && !"".Equals(((AreaAdmin)wm).TagName))
                            {
                                StrTagInfo = ((AreaAdmin)wm).TagName + "(" + StrTagInfo + ")";
                            }
                            //ExcelOperation.SaveData(index, 2, StrTagInfo);
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 1, StrTagInfo);
                            //string StrAreaType = "";

                            /* switch (((AreaAdmin)wm).AreaType)
                             * {
                             *   case AreaType.SimpleArea:
                             *       StrAreaType = "一般區域";
                             *       break;
                             *   case AreaType.ControlArea:
                             *       StrAreaType = "管制區域";
                             *       break;
                             *   case AreaType.DangerArea:
                             *       StrAreaType = "危險區域";
                             *       break;
                             * }*/
                            string StrTagType = "";
                            if (null != ((AreaAdmin)wm).TagAreaSt)
                            {
                                StrTagType = StrTagType + ((AreaAdmin)wm).TagAreaSt.GetAreasStr();
                            }
                            break;
                        }
                        else
                        {
                            continue;
                        }

                    case SpeceilAlarm.Resid:
                        if ("PersonRes".Equals(StrClassName))
                        {
                            StrWarmType = "人員未移動警報";
                            string StrTagInfo = ((PersonRes)wm).TD[0].ToString("X2") + ((PersonRes)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((PersonRes)wm).TagName && !"".Equals(((PersonRes)wm).TagName))
                            {
                                StrTagInfo = ((PersonRes)wm).TagName + "(" + StrTagInfo + ")";
                            }
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 1, StrTagInfo);
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 6, ((PersonRes)wm).ResTime + "(" + ((PersonRes)wm).BasicResTime + ") s");
                            break;
                        }
                        else
                        {
                            continue;
                        }

                    case SpeceilAlarm.TagDis:
                        if ("TagDis".Equals(StrClassName))
                        {
                            StrWarmType = "卡片異常警報";
                            string StrTagInfo = ((TagDis)wm).TD[0].ToString("X2") + ((TagDis)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((TagDis)wm).TagName && !"".Equals(((TagDis)wm).TagName))
                            {
                                StrTagInfo = ((TagDis)wm).TagName + "(" + StrTagInfo + ")";
                            }
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 5, StrTagInfo);
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 5, ((TagDis)wm).SleepTime + " s");
                            break;
                        }
                        else
                        {
                            continue;
                        }

                    case SpeceilAlarm.ReferDis:
                        if ("ReferDis".Equals(StrClassName))
                        {
                            StrWarmType = "參考點異常警報";
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 7, ((ReferDis)wm).SleepTime + " s");
                            break;
                        }
                        else
                        {
                            continue;
                        }

                    case SpeceilAlarm.NodeDis:
                        if ("NodeDis".Equals(StrClassName))
                        {
                            StrWarmType = "數據節點警報";

                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 8, ((NodeDis)wm).SleepTime + " s");
                            break;
                        }
                        else
                        {
                            continue;
                        }

                    default:
                        StrWarmType = "未知警報類型";
                        if ("BattLow".Equals(StrClassName))
                        {
                            StrWarmType = "低電量警報";
                            string StrTagInfo = ((BattLow)wm).TD[0].ToString("X2") + ((BattLow)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((BattLow)wm).TagName && !"".Equals(((BattLow)wm).TagName))
                            {
                                StrTagInfo = ((BattLow)wm).TagName + "(" + StrTagInfo + ")";
                            }
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 1, StrTagInfo);
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 4, ((BattLow)wm).Batt + "(" + ((BattLow)wm).BasicBatt + ") %");
                        }
                        else if ("PersonHelp".Equals(StrClassName))
                        {
                            StrWarmType = "人員求救警報";
                            string StrTagInfo = ((PersonHelp)wm).TD[0].ToString("X2") + ((PersonHelp)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((PersonHelp)wm).TagName && !"".Equals(((PersonHelp)wm).TagName))
                            {
                                StrTagInfo = ((PersonHelp)wm).TagName + "(" + StrTagInfo + ")";
                            }

                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 1, StrTagInfo);
                        }
                        else if ("AreaAdmin".Equals(StrClassName))
                        {
                            StrWarmType = "區域管制警報";
                            //string StrAreaType = "";
                            string StrTagInfo = ((AreaAdmin)wm).TD[0].ToString("X2") + ((AreaAdmin)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((AreaAdmin)wm).TagName && !"".Equals(((AreaAdmin)wm).TagName))
                            {
                                StrTagInfo = ((AreaAdmin)wm).TagName + "(" + StrTagInfo + ")";
                            }

                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 1, StrTagInfo);

                            /* switch (((AreaAdmin)wm).AreaType)
                             * {
                             *   case AreaType.SimpleArea:
                             *       StrAreaType = "一般區域";
                             *       break;
                             *   case AreaType.ControlArea:
                             *       StrAreaType = "管制區域";
                             *       break;
                             *   case AreaType.DangerArea:
                             *       StrAreaType = "危險區域";
                             *       break;
                             * }*/
                            string StrTagType = "";
                            if (null != ((AreaAdmin)wm).TagAreaSt)
                            {
                                StrTagType = StrTagType + ((AreaAdmin)wm).TagAreaSt.GetAreasStr();
                            }
                        }
                        else if ("PersonRes".Equals(StrClassName))
                        {
                            StrWarmType = "人員未移動警報";
                            string StrTagInfo = ((PersonRes)wm).TD[0].ToString("X2") + ((PersonRes)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((PersonRes)wm).TagName && !"".Equals(((PersonRes)wm).TagName))
                            {
                                StrTagInfo = ((PersonRes)wm).TagName + "(" + StrTagInfo + ")";
                            }
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 1, StrTagInfo);
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 6, ((PersonRes)wm).ResTime + "(" + ((PersonRes)wm).BasicResTime + ") s");
                        }
                        else if ("TagDis".Equals(StrClassName))
                        {
                            StrWarmType = "卡片異常警報";
                            string StrTagInfo = ((TagDis)wm).TD[0].ToString("X2") + ((TagDis)wm).TD[1].ToString("X2");
                            //卡片信息
                            if (null != ((TagDis)wm).TagName && !"".Equals(((TagDis)wm).TagName))
                            {
                                StrTagInfo = ((TagDis)wm).TagName + "(" + StrTagInfo + ")";
                            }
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 1, StrTagInfo);
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 5, ((TagDis)wm).SleepTime + " s");
                        }
                        else if ("ReferDis".Equals(StrClassName))
                        {
                            StrWarmType = "參考點異常警報";
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 7, ((ReferDis)wm).SleepTime + " s");
                        }
                        else
                        if ("NodeDis".Equals(StrClassName))
                        {
                            StrWarmType = "數據節點警報";
                            MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 8, ((NodeDis)wm).SleepTime + " s");
                        }
                        break;
                    }
                    MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 2, StrRouterInfo);
                    MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 3, StrAreaInfo);
                    MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 9, wm.AlarmTime.ToString());

                    if (DateTime.Compare(wm.AlarmTime, wm.ClearAlarmTime) != 0)
                    {
                        MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 10, wm.ClearAlarmTime.ToString());
                    }
                    MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 11, wm.isHandler.ToString());
                    MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 12, wm.isClear.ToString());
                    MyNpoiLib.writeToCell(MyNpoiLib.sheet1, index, 0, StrWarmType);
                    index++;
                }
                MyNpoiLib.WriteToFile(StrFilePath);
                MessageBox.Show("導出文件成功!");
            }
        }
        /// <summary>
        /// Gets the file items.
        /// </summary>
        /// <param name="fileOperation">The file operation.</param>
        /// <param name="projectService">The project service.</param>
        /// <returns>The files to have operations on.</returns>
        private IEnumerable<IProjectItemService> GetFileItems(
            FileOperation fileOperation, 
            IProjectService projectService)
        {
            TraceService.WriteLine("FileOperationService::GetFileItems");

            List<IProjectItemService> fileItemServices = new List<IProjectItemService>();

            if (string.IsNullOrEmpty(fileOperation.Directory) == false)
            {
                IProjectItemService projectItemService = projectService.GetFolder(fileOperation.Directory);

                if (projectItemService != null)
                {
                    if (string.IsNullOrEmpty(fileOperation.File) == false)
                    {
                        fileItemServices.Add(projectItemService.GetProjectItem(fileOperation.File));
                    }

                    else
                    {
                        IEnumerable<IProjectItemService> projectItemServices = projectItemService.GetCSharpProjectItems();

                        foreach (IProjectItemService childProjectItemService in projectItemServices)
                        {
                            TraceService.WriteDebugLine("FileOperationService::GetFileItems File=" + childProjectItemService.Name);
                            fileItemServices.Add(childProjectItemService);
                        }
                    }
                }
                else
                {
                    TraceService.WriteDebugLine("Directory " + fileOperation.Directory + " not found");
                }
            }
            else
            {
                fileItemServices.Add(projectService.GetProjectItem(fileOperation.File));
            }

            TraceService.WriteDebugLine("FileOperationService::GetFileItems fileItemServicesCount=" + fileItemServices.Count);

            return fileItemServices;
        }
示例#54
0
        /// <summary>
        /// 保存
        /// </summary>
        void UCPersonalSet_SaveEvent(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            string opName = "修改密码";

            if (tabControlEx1.SelectedIndex == 0)
            { //密码
                List <SQLObj> listSql = new List <SQLObj>();
                opName = "修改密码";
                if (GlobalStaticObj.PassWord != txtpassword.Caption.Trim())
                {
                    Utility.Common.Validator.SetError(errorProvider1, txtpassword, "旧密码输入不正确!");
                    return;
                }
                if (!Utility.Common.ValidateUtil.IsPassword(txtpassword_new.Caption.Trim()))
                {
                    Utility.Common.Validator.SetError(errorProvider1, txtpassword_new, "密码为6-20字母数字混合组成!");
                    return;
                }
                if (txtpassword_new.Caption.Trim() != txtpassword_new_d.Caption.Trim())
                {
                    Utility.Common.Validator.SetError(errorProvider1, txtpassword_new_d, "两次密码输入不一致!");
                    return;
                }

                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("password", this.txtpassword_new.Caption.Trim());
                dic.Add("update_by", GlobalStaticObj.UserID);
                dic.Add("update_time", Common.LocalDateTimeToUtcLong(HXCPcClient.GlobalStaticObj.CurrentDateTime).ToString());

                if (DBHelper.Submit_AddOrEdit("修改用户密码", "sys_user", "user_id", GlobalStaticObj.UserID, dic))
                {
                    GlobalStaticObj.PassWord = txtpassword_new.Text.Trim();
                    MessageBoxEx.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else
                {
                    MessageBoxEx.Show("保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else if (tabControlEx1.SelectedIndex == 1)
            { //个人信息
                try
                {
                    string msg = "";
                    bool   bln = Validator(ref msg);
                    if (!bln)
                    {
                        return;
                    }
                    string currUser_id = "";;

                    string keyName  = string.Empty;
                    string keyValue = string.Empty;
                    Dictionary <string, string> dicFileds = new Dictionary <string, string>();

                    dicFileds.Add("user_name", txtuser_name.Caption.Trim());                                          //人员姓名
                    dicFileds.Add("land_name", txtland_name.Caption.Trim());                                          //账号
                    dicFileds.Add("user_phone", txtuser_phone.Caption.Trim());                                        //手机
                    dicFileds.Add("user_telephone", txtuser_telephone.Caption.Trim());                                //固话
                    dicFileds.Add("org_id", txcorg_name.Tag.ToString().Trim());                                       //组织id
                    dicFileds.Add("sex", cbosex.SelectedValue.ToString());                                            //性别
                    dicFileds.Add("user_fax", txtuser_fax.Caption.Trim());                                            //传真
                    dicFileds.Add("idcard_type", cboidcard_type.SelectedValue.ToString());                            //证件类型
                    dicFileds.Add("user_email", txtuser_email.Caption.Trim());                                        //邮箱
                    dicFileds.Add("idcard_num", txtidcard_num.Caption.Trim());                                        //证件号码
                    dicFileds.Add("user_address", txtuser_address.Caption.Trim());                                    //联系地址
                    dicFileds.Add("remark", txtremark.Caption.Trim());                                                //备注

                    dicFileds.Add("nation", cbonation.SelectedValue.ToString());                                      //民族
                    dicFileds.Add("graduate_institutions", txtgraduate_institutions.Caption.Trim());                  //毕业学校
                    dicFileds.Add("technical_expertise", txttechnical_expertise.Caption.Trim());                      //技术特长
                    dicFileds.Add("user_height", txtuser_height.Caption.Trim());                                      //身高
                    dicFileds.Add("native_place", txtnative_place.Caption.Trim());                                    //籍贯
                    dicFileds.Add("specialty", txtspecialty.Caption.Trim());                                          //专业
                    dicFileds.Add("entry_date", Common.LocalDateTimeToUtcLong(dtpentry_date.Value).ToString());       //  入职日期
                    dicFileds.Add("user_weight", txtuser_weight.Caption.Trim());                                      //体重
                    dicFileds.Add("register_address", txtregister_address.Caption.Trim());                            //户籍所在地
                    dicFileds.Add("graduate_date", Common.LocalDateTimeToUtcLong(dtpgraduate_date.Value).ToString()); // 毕业时间
                    dicFileds.Add("wage", txtwage.Caption.Trim());                                                    // 工资
                    dicFileds.Add("birthday", Common.LocalDateTimeToUtcLong(dtpbirthday.Value).ToString());           // 出生日期
                    dicFileds.Add("education", cboeducation.SelectedValue.ToString());                                //学历
                    dicFileds.Add("position", cboposition.SelectedValue.ToString());                                  //岗位
                    dicFileds.Add("political_status", txtpolitical_status.Caption.Trim());                            //政治面貌
                    dicFileds.Add("level", cbolevel.SelectedValue.ToString());                                        //级别

                    dicFileds.Add("health", cbojkzk.SelectedValue.ToString());                                        //健康状况

                    string nowUtcTicks = Common.LocalDateTimeToUtcLong(HXCPcClient.GlobalStaticObj.CurrentDateTime).ToString();
                    dicFileds.Add("update_by", HXCPcClient.GlobalStaticObj.UserID);
                    dicFileds.Add("update_time", nowUtcTicks);

                    keyName     = "user_id";
                    keyValue    = GlobalStaticObj.UserID;
                    currUser_id = GlobalStaticObj.UserID;
                    opName      = "更新人员管理";

                    bln = DBHelper.Submit_AddOrEdit(opName, "sys_user", keyName, keyValue, dicFileds);

                    if (bln)
                    {
                        string photo = string.Empty;
                        if (picuser.Tag != null)
                        {
                            photo = Guid.NewGuid().ToString() + Path.GetExtension(picuser.Tag.ToString());
                            if (!FileOperation.UploadFile(picuser.Tag.ToString(), photo))
                            {
                                return;
                            }
                        }

                        List <SQLObj> listSql = new List <SQLObj>();
                        listSql = AddPhoto(listSql, currUser_id, photo);
                        DBHelper.BatchExeSQLMultiByTrans(opName, listSql);

                        txtuser_name.ReadOnly             = true;
                        txtuser_phone.ReadOnly            = true;
                        txtuser_telephone.ReadOnly        = true;
                        txtremark.ReadOnly                = true;
                        txcorg_name.ReadOnly              = true;
                        txtuser_fax.ReadOnly              = true;
                        txtuser_email.ReadOnly            = true;
                        txtidcard_num.ReadOnly            = true;
                        txtuser_address.ReadOnly          = true;
                        txtgraduate_institutions.ReadOnly = true;
                        txttechnical_expertise.ReadOnly   = true;
                        txtuser_height.ReadOnly           = true;
                        txtnative_place.ReadOnly          = true;
                        txtspecialty.ReadOnly             = true;
                        txtwage.ReadOnly             = true;
                        txtuser_weight.ReadOnly      = true;
                        txtregister_address.ReadOnly = true;
                        txtpolitical_status.ReadOnly = true;

                        cbosex.Enabled           = false;
                        cboidcard_type.Enabled   = false;
                        cbonation.Enabled        = false;
                        dtpentry_date.Enabled    = false;
                        dtpgraduate_date.Enabled = false;
                        dtpbirthday.Enabled      = false;
                        cboeducation.Enabled     = false;
                        cboposition.Enabled      = false;
                        cbolevel.Enabled         = false;
                        cbojkzk.Enabled          = false;//健康状况
                        picuser.Enabled          = false;

                        MessageBoxEx.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                    }
                    else
                    {
                        MessageBoxEx.Show("保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxEx.Show("保存失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else if (tabControlEx1.SelectedIndex == 2)
            { //自动锁屏
                try
                {
                    if (rdbis_use_login_password_n.Checked && txtset_password.Caption.Trim().Length == 0)
                    {
                        Utility.Common.Validator.SetError(errorProvider1, txtset_password, "请输入口令!");
                        return;
                    }
                    string keyName  = string.Empty;
                    string keyValue = string.Empty;
                    opName = "自动锁屏";
                    Dictionary <string, string> Fileds = new Dictionary <string, string>();

                    Fileds.Add("is_open", rdbis_open_y.Checked ? "1" : "0");
                    string sys_lock_screen_time = Math.Round(numsys_lock_screen_time.Value, 0).ToString();
                    Fileds.Add("sys_lock_screen_time", sys_lock_screen_time);
                    Fileds.Add("is_use_login_password", rdbis_use_login_password_y.Checked ? "1" : "0");
                    Fileds.Add("set_password", txtset_password.Caption.ToString().Trim());

                    string nowUtcTicks = Common.LocalDateTimeToUtcLong(HXCPcClient.GlobalStaticObj.CurrentDateTime).ToString();
                    Fileds.Add("update_by", HXCPcClient.GlobalStaticObj.UserID);
                    Fileds.Add("update_time", nowUtcTicks);
                    if (lock_screen_id == "")
                    {
                        Fileds.Add("lock_screen_id", Guid.NewGuid().ToString());//新ID
                        Fileds.Add("create_by", HXCPcClient.GlobalStaticObj.UserID);
                        Fileds.Add("create_time", nowUtcTicks);
                    }
                    else
                    {
                        keyName  = "lock_screen_id";
                        keyValue = lock_screen_id;
                        opName   = "更新自动锁屏";
                    }
                    bool bln = DBHelper.Submit_AddOrEdit(opName, "sys_automatic_lock_screen", keyName, keyValue, Fileds);
                    if (bln)
                    {
                        rdbis_open_y.Enabled = false;
                        rdbis_open_n.Enabled = false;
                        rdbis_use_login_password_y.Enabled = false;
                        rdbis_use_login_password_n.Enabled = false;

                        numsys_lock_screen_time.ReadOnly = true;
                        txtset_password.ReadOnly         = true;
                        MessageBoxEx.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                    }
                    else
                    {
                        MessageBoxEx.Show("保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxEx.Show("保存失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
        public static void FileOperationToBreakLeaseRequestCall(FileOperation operation, OperatorType operatorType, ModelDialectRevision dialect)
        {
            Condition.IsTrue(state == ModelState.Connected);
            Condition.IsNull(request);
            Condition.IsNotNull(smb2Lease);
            Condition.IsFalse(smb2Lease.Breaking);
            Condition.IsFalse(smb2Lease.LeaseState == (uint)LeaseStateValues.SMB2_LEASE_NONE);
            Condition.IsTrue(dialect <= config.MaxSmbVersionSupported);

            if (operatorType == OperatorType.SameClientId || operatorType == OperatorType.SameClientGuidDifferentLeaseKey)
            {
                switch (negotiateDialect)
                {
                    case DialectRevision.Smb2002:
                        Condition.IsTrue(dialect == ModelDialectRevision.Smb2002);
                        break;
                    case DialectRevision.Smb21:
                        Condition.IsTrue(dialect == ModelDialectRevision.Smb21);
                        break;
                    case DialectRevision.Smb30:
                        Condition.IsTrue(dialect == ModelDialectRevision.Smb30);
                        break;
                    case DialectRevision.Smb302:
                        Condition.IsTrue(dialect == ModelDialectRevision.Smb302);
                        break;
                    default:
                        Condition.Fail();
                        break;
                }
            }
            else
            {
                // Limit the dialect which is used by second client for se exploration.
                Condition.IsTrue(dialect == ModelDialectRevision.Smb2002);
            }

            request = new ModelFileOperationRequest(operation, operatorType, dialect);
        }