示例#1
0
        internal override async Task <bool> ChangePermissionsync(SmartItem item, string permission)
        {
            SmartItem eitem;

            if (await _commandChmodAsync(item.FullName, permission))
            {
                eitem = GetServerItem(item.ItemName, item.ItemFolder);
                if (eitem != null)
                {
                    eitem.Status = ItemStatus.PermissionChanged;
                    TransferEvents.ItemStatusChanged(eitem);
                }

                AppHistory.Add(item.ItemName, item.ItemFolder, item.Permissions, permission, ItemStatus.PermissionChanged);
                item.Permissions = permission;
                return(true);
            }
            else if (await retryAsync())
            {
                return(await ChangePermissionsync(item, permission));
            }

            AppHistory.Add(item.ItemName, item.ItemFolder, item.Permissions, permission, ItemStatus.PermissionError);

            eitem = GetServerItem(item.ItemName, item.ItemFolder);
            if (eitem != null)
            {
                eitem.Status = ItemStatus.PermissionError;
                TransferEvents.ItemStatusChanged(eitem);
            }

            return(false);
        }
示例#2
0
        private void AddNewHistory(int _ekanbanHisId)
        {
            try
            {
                AppHistory his = new AppHistory
                {
                    SysActionCode = (int)SysActionCode.EKANBAN_ADD_NEW_ITEM,
                    DateTime      = DateTime.Now,
                    Description   = $"Add new Ekanban information: {SelectedEKanbanDevice.Name}",
                    Remark        = $"PO:{SelectedSchedule.PoNumber}, Line:{SelectedProductionLine.LineName}, Sequence:{SelectedSequence.SequenceNo}",
                };
                SysHistoryQuery.AddNewAppHistory(his);
                EKanbanAddHis addHis = new EKanbanAddHis
                {
                    DateTime            = DateTime.Now,
                    Added               = true,
                    EKanbanHis_Id       = _ekanbanHisId,
                    OriginalSequence_Id = SelectedSequence.id,
                    SequenceNo          = SelectedSequence.SequenceNo,
                    SequenceQty         = SelectedSequence.Quantity,
                };

                SysHistoryQuery.AddNewAddHistory(addHis);
            }
            catch (Exception e)
            { }
        }
示例#3
0
        internal override async Task <bool> CreateFolderAsync(string name, string path, bool replaceSpaces = true)
        {
            if (path.NullEmpty())
            {
                return(false);
            }

            SmartItem item = GetServerItem(name, path);

            if (item == null)
            {
                item = InsertItem(new SmartItem(name, path, DateTime.Now.Ticks));
            }

            if (item != null)
            {
                item.Status = ItemStatus.Creating;
                TransferEvents.ItemStatusChanged(item);
            }

            bool created = await _createServerFolderAsync(path + name);

            AppHistory.Add(name, path, " ", path + name, (created) ? ItemStatus.Created : ItemStatus.CreateError);
            item = GetServerItem(name, path);
            if (item != null)
            {
                item.HasError = !created;
                item.Status   = (created) ? ItemStatus.Created : ItemStatus.CreateError;
                TransferEvents.ItemStatusChanged(item);
            }

            return(created);
        }
示例#4
0
        void WriteHistory(String action, Boolean success, String remark)
        {
            var app = Session["App"] as App;
            var ns  = Session as INetSession;
            var ip  = ns.Remote.Host;

            AppHistory.Create(app, action, success, remark, Local + "", ip);
        }
示例#5
0
        public void AppHistoryLongDescriptionShouldBeTrimmedTest()
        {
            string desc = Utility.RandomStringGenerator(250);

            var obj = new AppHistory(AppTable.TableName, AppHistoryType.Add, 1, 1, desc);

            Assert.IsTrue(obj.Description.Length == 200);
        }
示例#6
0
 private void CheckBoxSaveHistory_Checked(object sender, RoutedEventArgs e)
 {
     HistoryList.IsEnabled = false;
     AppHistory.IsEnabled  = true;
     AppSettings.Set("App", "SaveHistory", true);
     AppHistory.Save();
     HistoryList.IsEnabled = true;
 }
示例#7
0
        private async void ButtonEmptyList_Click(object sender, RoutedEventArgs e)
        {
            HistoryList.IsEnabled = false;
            AppHistory.Clear();
            await AppHistory.Delete();

            HistoryList.IsEnabled = true;
        }
示例#8
0
        internal override async Task <bool> DeleteItemAsync(SmartItem item)
        {
            SmartItem eitem = GetServerItem(item.ItemName, item.ItemFolder);

            if (eitem != null)
            {
                eitem.Status = ItemStatus.Deleting;
                TransferEvents.ItemStatusChanged(eitem);
            }

            bool deleted = false;

            if (item.IsFile)
            {
                if (await _commandDeleAsync(item.FullName))
                {
                    deleted = true;
                }
            }
            else if (isRMDA)
            {
                if (await _commandRmdaAsync(item.FullName))
                {
                    deleted = true;
                }
            }
            else if (await _deleteFolderAsync(item.FullName))
            {
                deleted = true;
            }

            if (deleted)
            {
                AppHistory.Add(item.ItemName, item.ItemFolder, item.ItemFolder, " ", ItemStatus.Deleted);
                eitem = GetServerItem(item.ItemName, item.ItemFolder);
                if (eitem != null)
                {
                    Items.Remove(eitem);
                }

                return(true);
            }
            else if (await retryAsync())
            {
                return(await DeleteItemAsync(item));
            }

            AppHistory.Add(item.ItemName, item.ItemFolder, item.ItemFolder, " ", ItemStatus.DeleteError);

            eitem = GetServerItem(item.ItemName, item.ItemFolder);
            if (eitem != null)
            {
                eitem.Status = ItemStatus.DeleteError;
                TransferEvents.ItemStatusChanged(eitem);
            }

            return(false);
        }
示例#9
0
        private async void CheckBoxSaveHistory_Unchecked(object sender, RoutedEventArgs e)
        {
            HistoryList.IsEnabled = true;
            AppHistory.IsEnabled  = false;
            AppSettings.Set("App", "SaveHistory", false);
            await AppHistory.Delete();

            HistoryList.IsEnabled = true;
        }
示例#10
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            HistoryListProgress     = true;
            HistoryList.ItemsSource = await AppHistory.GetItems();

            isLoaded = true;
            HistoryList.UnselectAll();
            historyListView     = CollectionViewSource.GetDefaultView(HistoryList.ItemsSource);
            HistoryListProgress = false;
        }
示例#11
0
        public void AppHistoryLongDescriptionShouldBeTrimmedTest()
        {
            var desc = new StringBuilder();

            for (var i = 0; i < 250; i++)
            {
                desc.Append(i);
            }
            var obj = new AppHistory(AppTable.TableName, AppHistoryType.Add, 1, 1, desc.ToString());

            Assert.IsTrue(obj.Description.Length == 200);
        }
示例#12
0
 public bool AddNewAppHistory(AppHistory _appHis)
 {
     try
     {
         using (HistoryContext = new HistoryContext(database))
         {
             HistoryContext.AppHistories.Add(_appHis);
             HistoryContext.SaveChanges();
             return(true);
         }
     }
     catch { return(false); }
 }
示例#13
0
 public bool UpdateAppHistory(AppHistory _appHis)
 {
     try
     {
         using (HistoryContext = new HistoryContext(database))
         {
             HistoryContext.Entry(_appHis).State = EntityState.Modified;
             HistoryContext.SaveChanges();
             return(true);
         }
     }
     catch { return(false); }
 }
示例#14
0
        public void AddNewSequenceViewer(Schedule _schedule)
        {
            SequenceCounter++;
            SequenceCtrl seqCtrl = new SequenceCtrl(_schedule, true);

            SequenceLoader.Controls.Add(new SequenceItem(seqCtrl, SequenceCounter));

            AppHistory his = new AppHistory
            {
                SysActionCode = (int)(SysActionCode.VIEW_SEQUENCE),
                Remark        = $"PO:{(_schedule as Schedule).PoNumber}",
            };

            SysHistoryQuery.AddNewAppHistory(his);
        }
示例#15
0
        private void Btn_Start2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Path2))
            {
                return;
            }

            bool   success = unblock.ComponentQuery.ClearAllModelComponents();
            string exp     = success == true ? "Successflly" : "Error";

            BeginInvoke(new MethodInvoker(() => { lb_Exeption2.Text = $"Clear Model component {exp}"; }));

            unblock.OledB_ReadComponentTable(Path2);

            if (unblock._AutoCutTable == null || unblock._AutoCutTable.Rows.Count == 0)
            {
                MessageBox.Show("_AutoCutTable is null or have no row");
                return;
            }
            try
            {
                unblock.ClearComponent();
                Thread thread = new Thread(() =>
                {
                    Handle_CuttingComponents(unblock._AutoCutTable, true);
                    Handle_CuttingComponents(unblock._BeamCutTable, false);

                    AppHistory his = new AppHistory
                    {
                        AppUser_Id    = User.id,
                        SysActionCode = (int)SysActionCode.UPDATE_COMPONENT,
                        Description   = Path2,
                    };
                    unblock.SysHistoryQuery.AddNewAppHistory(his);

                    MessageBox.Show("Update component successfully");
                });
                thread.Start();
            }
            catch
            {
                MessageBox.Show("Error occure while update components to database");
            }
        }
示例#16
0
        internal override async Task <bool> RenameItemAsync(SmartItem item, string toName)
        {
            string newName = item.ItemFolder + toName;

            SmartItem eitem = GetServerItem(item.ItemName, item.ItemFolder);

            if (eitem != null)
            {
                eitem.Status = ItemStatus.Renaming;
                TransferEvents.ItemStatusChanged(eitem);
            }

            if (await commandRnfrAsync(item.FullName) && await commandRntoAsync(newName))
            {
                AppHistory.Add(toName, item.ItemFolder, item.ItemName, toName, ItemStatus.Renamed);
                eitem = GetServerItem(item.ItemName, item.ItemFolder, null, true);
                if (eitem != null)
                {
                    eitem.ItemName = toName;
                    eitem.FullName = newName;
                    eitem.Status   = ItemStatus.Renamed;
                    TransferEvents.ItemStatusChanged(eitem);
                }
                return(true);
            }
            else if (await retryAsync())
            {
                return(await RenameItemAsync(item, toName));
            }
            AppHistory.Add(item.ItemName, item.ItemFolder, item.ItemName, toName, ItemStatus.RenameError);

            eitem = GetServerItem(item.ItemName, item.ItemFolder);
            if (eitem != null)
            {
                eitem.Status = ItemStatus.RenameError;
                TransferEvents.ItemStatusChanged(eitem);
            }

            return(false);
        }
示例#17
0
        private void Btn_Start1_Click(object sender, EventArgs e)
        {
            unblock.ExcelColumnDef = ExcelColumnDef;

            if (Path1 == null || Path1 == "")
            {
                return;
            }

            Thread thead = new Thread(() =>
            {
                Handle_UpdateSequenceRoot();

                AppHistory his = new AppHistory
                {
                    AppUser_Id    = User.id,
                    SysActionCode = (int)SysActionCode.UPDATE_SEQUENCE,
                    Description   = Path1,
                };
                unblock.SysHistoryQuery.AddNewAppHistory(his);
            });

            thead.Start();
        }
示例#18
0
        internal override async Task <bool> MoveItemAsync(SmartItem item, string toPath)
        {
            SmartItem eitem = GetServerItem(item.ItemName, item.ItemFolder);

            if (eitem != null)
            {
                eitem.Status = ItemStatus.Moving;
                TransferEvents.ItemStatusChanged(eitem);
            }

            if (await commandRnfrAsync(item.FullName) && await commandRntoAsync(toPath + item.ItemName))
            {
                AppHistory.Add(item.ItemName, toPath, item.ItemFolder, toPath, ItemStatus.Moved);
                eitem = GetServerItem(item.ItemName, item.ItemFolder);
                if (eitem != null)
                {
                    Items.Remove(eitem);
                }
                return(true);
            }
            else if (await retryAsync())
            {
                return(await MoveItemAsync(item, toPath));
            }

            AppHistory.Add(item.ItemName, item.ItemFolder, item.ItemFolder, toPath, ItemStatus.MoveError);

            eitem = GetServerItem(item.ItemName, item.ItemFolder);
            if (eitem != null)
            {
                eitem.Status = ItemStatus.MoveError;
                TransferEvents.ItemStatusChanged(eitem);
            }

            return(false);
        }
示例#19
0
 void WriteHistory(String action, Boolean success, String remark) => AppHistory.Create(_App, action, success, remark, Local + "", _Net.Remote?.Host);
示例#20
0
        private void btn_Clear_Click(object sender, EventArgs e)
        {
            var dresult = MessageBox.Show("Do you really want to delete this Ekanban data?", "Question",
                                          MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dresult != DialogResult.Yes)
            {
                return;
            }

            int oldId = SelectedEKanbanInterface.id;

            ICollection <EKanbanLoading> EkanbanLoadings = EKanbanTaskQuery.GetEKanbanLoadings(SelectedEKanbanInterface.id);

            if (EKanbanTaskQuery.DeleteEKanbanInterface(SelectedEKanbanInterface))
            {
                MessageBox.Show("Clear Po from Ekanban succeesfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("An error orcured while delete Ekanban interface.\r\nError: Failed to delete Ekanban interface.", "Message",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            UpdateSelectedSchedule();
            UpdateSelectedEkanbanDevice();
            UpdateSelectedOriginalSequence();


            // Thêm mới Stock record
            var Stock = StockQuery.GetPrepareStockMeasure(SelectedSchedule);

            if (Stock == null)
            {
                return;
            }

            foreach (var item in EkanbanLoadings)
            {
                var seq = SequenceQuery.GetOriginalSequence(ShareFuncs.GetInt(item.OriginalSequence_Id));
                StockQuery.DeleteStockPreparing(Stock.id, ShareFuncs.GetInt(seq.SequenceNo));
            }

            try
            {
                // thêm mới history cho ekanban
                AppHistory his = new AppHistory
                {
                    SysActionCode = (int)SysActionCode.EKANBAN_CLEAR_ITEM,
                    DateTime      = DateTime.Now,
                    Description   = $"Clear Ekanban information: {SelectedEKanbanDevice.Name}",
                };

                SysHistoryQuery.AddNewAppHistory(his);

                var EkanbanHis = SysHistoryQuery.GetEKanbanHistoryByInterface(oldId);

                EKanbanClearHis addHis = new EKanbanClearHis
                {
                    DateTime      = DateTime.Now,
                    Removed       = true,
                    EKanbanHis_Id = EkanbanHis.id,
                };

                SysHistoryQuery.AddNewClearHistory(addHis);
            }
            catch (Exception ee)
            { }
        }