Ejemplo n.º 1
0
 public bool RemoveSMU(Manifest manif, SMU item)
 {
     using (var db = new OcphDbContext())
     {
         var trans = db.BeginTransaction();
         try
         {
             if (db.ManifestDetail.Delete(O => O.SMUId == item.Id))
             {
                 var note = string.Format(@"Menghapus SMU : T{0:D9} Dari Manifest MT{1:D8}", item.Id, manif.Id);
                 var his  = User.GenerateHistory(manif.Id, BussinesType.Manifest, ChangeType.Update, note);
                 if (db.Histories.Insert(his))
                 {
                     trans.Commit();
                     return(true);
                 }
             }
             throw new SystemException("Data Tidak Terhapus");
         }
         catch (Exception ex)
         {
             trans.Rollback();
             throw new SystemException(ex.Message);
         }
     }
 }
Ejemplo n.º 2
0
        private void DataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            detailsDg.IsReadOnly = true;
            SMU selectedRow = e.Row.DataContext as SMU;

            if (e.EditAction == DataGridEditAction.Commit)
            {
            }
        }
Ejemplo n.º 3
0
        public void SetCancelSMU(SMU selectedItem, string alasan)
        {
            using (var db = new OcphDbContext())
            {
                var trans = db.BeginTransaction();
                try
                {
                    if (selectedItem.ActiveStatus != ActivedStatus.Cancel)
                    {
                        var result = (from a in db.ManifestDetail.Where(O => O.SMUId == selectedItem.Id)
                                      join b in db.Manifest.Select() on a.manifestoutgoingId equals b.Id
                                      select b).FirstOrDefault();


                        if (result != null && result.IsTakeOff)
                        {
                            throw new SystemException(string.Format("T{0:D9} Tidak Dapat Dibatalkan \r\n Telah Berangkat Dengan Manifest Nomor MT{1:D9}", selectedItem.Id, result.Id));
                        }

                        if (result != null && !result.IsTakeOff)
                        {
                            throw new SystemException(string.Format("Batalkan T{0:D9} Dari Manifest Nomor MT{1:D8}", selectedItem.Id, result.Id));
                        }


                        ActivedStatus active  = ActivedStatus.Cancel;
                        var           updated = db.SMU.Update(O => new { O.ActiveStatus }, new smu {
                            Id = selectedItem.Id, ActiveStatus = active
                        }, O => O.Id == selectedItem.Id);
                        if (updated)
                        {
                            selectedItem.ActiveStatus = ActivedStatus.Cancel;
                            var his = User.GenerateHistory(selectedItem.Id, BussinesType.SMU, ChangeType.Cancel, alasan);
                            if (!db.Histories.Insert(his))
                            {
                                throw new SystemException("Gagal Diubah");
                            }

                            trans.Commit();
                        }
                        else
                        {
                            throw new SystemException("Gagal Diubah");
                        }
                    }
                    else
                    {
                        throw new SystemException("SMU Telah Batal");
                    }
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new SystemException(ex.Message);
                }
            }
        }
Ejemplo n.º 4
0
        private async void LoadData(SMU SMUSelected)
        {
            var datas = await context.GetSMUDetail(SMUSelected.Id);

            foreach (var item in datas)
            {
                OriginSource.Add(item);
            }
            RefreshAll();
        }
Ejemplo n.º 5
0
 public BrowseColliesViewModel(SMU selected)
 {
     SMUSelected = selected;
     MyTitle     = "Tambah Item PTI Ke SMU";
     Source      = new ObservableCollection <collies>();
     SourceView  = (CollectionView)CollectionViewSource.GetDefaultView(Source);
     LoadOutOfManifestData(selected.PTIId);
     OKCommand = new CommandHandler {
         CanExecuteAction = OKCommandValidate, ExecuteAction = OKCommandAction
     };
 }
Ejemplo n.º 6
0
        internal async void ShowDetails(SMU selectedSMU)
        {
            var res = await context.GetSMUDetail(selectedSMU.Id);

            selected.Details.Clear();

            foreach (var item in res)
            {
                selected.Details.Add(item);
            }
            GridWidth = new GridLength(30, GridUnitType.Star);
        }
Ejemplo n.º 7
0
        public bool ManifestIsTakeOf(SMU selectedItem)
        {
            using (var db = new OcphDbContext())
            {
                var result = db.ManifestDetail.Where(O => O.SMUId == selectedItem.Id).FirstOrDefault();
                if (result != null)
                {
                    var manifest = db.Manifest.Where(O => O.Id == result.manifestoutgoingId).FirstOrDefault();
                    if (manifest != null && manifest.IsTakeOff)
                    {
                        return(true);
                    }
                }

                return(false);
            }
        }
Ejemplo n.º 8
0
        public Task InsertPTIItemToSMU(SMU smuSelected, ObservableCollection <collies> source)
        {
            using (var db = new OcphDbContext())
            {
                var trans = db.BeginTransaction();
                try
                {
                    foreach (var item in source.Where(O => O.IsSended == true).ToList())
                    {
                        if (!db.SMUDetails.Insert(new smudetails {
                            colliesId = item.Id, SMUId = smuSelected.Id
                        }))
                        {
                            throw new SystemException("Data Tidak Tersimpan");
                        }

                        var note       = string.Format("Menambah Item Ke SMU No T{0:D9}-{1}-{2}-{3}-{4}-{5}", smuSelected.Id, item.Content, item.Kemasan, item.Pcs, item.Weight, item.TotalWeight);
                        var histDetail = User.GenerateHistory(smuSelected.Id, BussinesType.SMU, ChangeType.Update, note);
                        if (!db.Histories.Insert(histDetail))
                        {
                            throw new SystemException("Data Tidak Tersimpan");
                        }
                    }



                    if (source.Where(O => !O.IsSended).Count() <= 0)
                    {
                        if (!db.PTI.Update(O => new { O.OnSMU }, new pti {
                            OnSMU = true, Id = smuSelected.PTIId
                        }, O => O.Id == smuSelected.PTIId))
                        {
                            throw new SystemException("Data Tidak Tersimpan");
                        }
                    }
                    trans.Commit();
                    return(Task.FromResult(0));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new SystemException(ex.Message);
                }
            }
        }
Ejemplo n.º 9
0
 internal void RemoveItemCollies(SMU item)
 {
     try
     {
         if (!ManifestSelected.IsTakeOff)
         {
             if (context.RemoveSMU(ManifestSelected, item))
             {
                 ManifestSelected.Details.Remove(item);
                 Helpers.ShowMessage("SMU Telah Di Hapus");
             }
         }
         else
         {
             throw new SystemException("Pesawat Telah Berangkat, Data Tidak Dapat Dihapus");
         }
     }
     catch (Exception ex)
     {
         Helpers.ShowErrorMessage(ex.Message);
     }
 }
Ejemplo n.º 10
0
        public SplitSMUViewModel(SMU SMUSelected)
        {
            MyTitle          = "SPLIT SMU";
            SmuSelected      = SMUSelected;
            PindahkanCommand = new CommandHandler {
                CanExecuteAction = PindahkanValidate, ExecuteAction = PindahkanAction
            };
            KembaliCommand = new CommandHandler {
                CanExecuteAction = KembaliValidate, ExecuteAction = KembaliAction
            };
            SaveCommand = new CommandHandler {
                CanExecuteAction = SaveValidate, ExecuteAction = SaveAction
            };
            CancelCommand = new CommandHandler {
                CanExecuteAction = x => true, ExecuteAction = x => WindowClose()
            };

            OriginSource      = new ObservableCollection <SMUDetail>();
            DestinationSource = new ObservableCollection <SMUDetail>();

            OriginView      = (CollectionView)CollectionViewSource.GetDefaultView(OriginSource);
            DestinationView = (CollectionView)CollectionViewSource.GetDefaultView(DestinationSource);
            LoadData(SMUSelected);
        }
        static void Main(string[] args)
        {
            double[] curr = new double[4];
            double[] volt = new double[4];

            int    ret             = 0;
            int    testHead        = 0;
            int    testSite        = 0;
            int    initOption      = 0xf;
            bool   offline         = false;
            String HardwareProfile = null;

            HardwareProfile = Path.Combine(Environment.CurrentDirectory, "example.amap");

            SMU smu = null;

            try
            {
                smu = new SMU(HardwareProfile, testHead, testSite, offline, initOption);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadLine();
            }

            //V1-4 (AM430e)

            ret += smu.SetIntegration("V1-4", SmuIntegration.Is50Hz);
            ret += smu.SetNPLC("V1-4", 1);
            ret += smu.SetBandwidth("V1-4", SmuBandwidth.Normal);

            ret += smu.ClampCurrent("V1-4", 100e-6);
            ret += smu.DriveVoltage("V1-4", 0);
            ret += smu.OnSmuPin("V1-4", true, false);
            delay_s(1e-3);
            ret += smu.DriveVoltage("V1-4", 3.3);
            delay_s(1e-3);
            ret += smu.ReadVoltage("V1-4", out volt);
            ret += smu.ReadCurrent("V1-4", out curr);

            Console.WriteLine("V1-4");
            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine("curr[" + i + "]: " + curr[i] + "; volt[" + i + "]: " + volt[i]);
            }

            ret += smu.DriveVoltage("V1-4", 0);
            delay_s(1e-3);
            ret += smu.OffSmuPin("V1-4");

            //Vcc (AM471e)

            ret += smu.SetIntegration("Vcc", SmuIntegration.Is50Hz);
            ret += smu.SetNPLC("Vcc", 1);
            ret += smu.SetBandwidth("Vcc", SmuBandwidth.Normal);

            ret += smu.ClampCurrent("Vcc", 100e-6);
            ret += smu.DriveVoltage("Vcc", 0);
            ret += smu.OnSmuPin("Vcc", true, false);
            delay_s(1e-3);
            ret += smu.DriveVoltage("Vcc", 3.3);
            delay_s(1e-3);
            ret += smu.ReadVoltage("Vcc", out volt);
            ret += smu.ReadCurrent("Vcc", out curr);

            Console.WriteLine();
            Console.WriteLine("Vcc:");
            Console.WriteLine("curr: " + curr[0] + "; volt: " + volt[0]);

            ret += smu.DriveVoltage("Vcc", 0);
            delay_s(1e-3);
            ret += smu.OffSmuPin("Vcc");

            Console.ReadLine();
        }
Ejemplo n.º 12
0
        public Task <Tuple <SMU, SMU> > SplitSMU(SMU smuSelected, ObservableCollection <SMUDetail> originSource, ObservableCollection <SMUDetail> destinationSource)
        {
            using (var db = new OcphDbContext())
            {
                var trans = db.BeginTransaction();
                try
                {
                    //remove selected Move
                    foreach (var item in destinationSource.ToList())
                    {
                        if (!db.SMUDetails.Delete(O => O.SMUId == item.Id && O.colliesId == item.ColliesId))
                        {
                            throw new SystemException("Smu Gagal di Split");
                        }
                    }
                    var firstColly = originSource.FirstOrDefault();
                    var ptiModel   = new PTI {
                        Id = firstColly.PTIId, ShiperID = smuSelected.ShiperId, RecieverId = smuSelected.RecieverId, PayType = firstColly.PayType
                    };

                    var source = new ObservableCollection <collies>();
                    foreach (var item in destinationSource)
                    {
                        source.Add(new collies {
                            Id = item.ColliesId, Content = item.Content, IsSended = true, Pcs = item.Pcs, Price = item.Price, PtiId = item.PTIId, Weight = item.Weight
                        });
                    }

                    smuSelected.Pcs    = originSource.Sum(O => O.Pcs);
                    smuSelected.Weight = originSource.Sum(O => O.Weight);
                    smuSelected.Biaya  = originSource.Sum(O => O.Biaya);

                    //SUMU
                    var smudata = new smu {
                        PTIId = smuSelected.PTIId, CreatedDate = DateTime.Now
                    };
                    smudata.Id = db.SMU.InsertAndGetLastID(smudata);
                    if (smudata.Id <= 0)
                    {
                        throw new SystemException("Data Tidak Tersimpan");
                    }

                    foreach (var item in source.Where(O => O.IsSended))
                    {
                        var data = new smudetails {
                            colliesId = item.Id, SMUId = smudata.Id
                        };
                        if (!db.SMUDetails.Insert(data))
                        {
                            throw new SystemException("Data Tidak Tersimpan");
                        }
                    }


                    var memo = string.Format("Split Dari SMU T{0:D9}", smuSelected.Id);

                    var history = User.GenerateHistory(smudata.Id, BussinesType.SMU, ChangeType.Create, memo);
                    if (!db.Histories.Insert(history))
                    {
                        throw new SystemException("Gagal Simpan Data");
                    }

                    SMU sm = new SMU
                    {
                        CreatedDate  = smuSelected.CreatedDate,
                        Id           = smudata.Id,
                        IsSended     = false,
                        Pcs          = source.Sum(O => O.Pcs),
                        RecieverId   = smuSelected.RecieverId,
                        RecieverName = smuSelected.RecieverName,
                        ShiperId     = ptiModel.ShiperID,
                        ShiperName   = smuSelected.ShiperName,
                        Weight       = source.Sum(O => O.Weight),
                        Biaya        = source.Sum(O => O.Biaya)
                    };

                    //
                    trans.Commit();
                    return(Task.FromResult(new Tuple <SMU, SMU>(smuSelected, sm)));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new SystemException(ex.Message);
                }
            }
        }
Ejemplo n.º 13
0
        public Task <SMU> CreateNewSMU(PTI pTISelected, ObservableCollection <collies> source)
        {
            using (var db = new OcphDbContext())
            {
                var date  = DateTime.Now;
                var trans = db.BeginTransaction();
                try
                {
                    var smudata = new smu {
                        PTIId = pTISelected.Id, CreatedDate = pTISelected.CreatedDate
                    };
                    smudata.Id = db.SMU.InsertAndGetLastID(smudata);
                    if (smudata.Id <= 0)
                    {
                        throw new SystemException("Data Tidak Tersimpan");
                    }

                    foreach (var item in source.Where(O => O.IsSended))
                    {
                        var data = new smudetails {
                            colliesId = item.Id, SMUId = smudata.Id
                        };
                        if (!db.SMUDetails.Insert(data))
                        {
                            throw new SystemException("Data Tidak Tersimpan");
                        }
                    }


                    if (source.Where(O => !O.IsSended).Count() <= 0)
                    {
                        if (!db.PTI.Update(O => new { O.OnSMU }, new pti {
                            Id = pTISelected.Id, OnSMU = true
                        }, O => O.Id == pTISelected.Id))
                        {
                            throw new SystemException("Data Tidak Tersimpan");
                        }
                        else
                        {
                            pTISelected.OnSMU = true;
                        }

                        var h = User.GenerateHistory(pTISelected.Id, BussinesType.PTI, ChangeType.Update, string.Format("Dibuatkan SMU dengan Nomor T{0:D9}", smudata.Id));
                        if (!db.Histories.Insert(h))
                        {
                            throw new SystemException("Gagal Simpan Data");
                        }
                    }



                    var history = User.GenerateHistory(smudata.Id, BussinesType.SMU, ChangeType.Create, "");
                    if (!db.Histories.Insert(history))
                    {
                        throw new SystemException("Gagal Simpan Data");
                    }

                    SMU sm = new SMU
                    {
                        CreatedDate  = date,
                        Id           = smudata.Id,
                        IsSended     = false,
                        Pcs          = source.Sum(O => O.Pcs),
                        RecieverId   = pTISelected.RecieverId,
                        RecieverName = pTISelected.RecieverName,
                        ShiperId     = pTISelected.ShiperID,
                        ShiperName   = pTISelected.ShiperName,
                        Weight       = source.Sum(O => O.Weight),
                        Biaya        = source.Sum(O => O.Biaya)
                    };

                    trans.Commit();
                    return(Task.FromResult(sm));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new SystemException(ex.Message);
                }
            }
        }
Ejemplo n.º 14
0
        public MainForm()
        {
            InitializeComponent();
            ols       = new Ols();
            hMutexPci = new Mutex();
            smu       = new Zen2Settings();

            try
            {
                CheckOlsStatus();
            }
            catch (ApplicationException ex)
            {
                MessageBox.Show(ex.Message, @"Error");
                Dispose();
                Application.Exit();
            }

            CPUID = GetCpuInfo() & 0xFFFFFFF0;
#if !DEBUG
            if (CPUID != 0x00830F00 && CPUID != 0x00830F10) // EPYC Rome ES
            {
                MessageBox.Show(@"CPU not supported!", @"Error");
                Dispose();
                Application.Exit();
                return;
            }
#endif
#if DEBUG
            var res = MessageBox.Show(
                @"This is an experimental version of this software. Keep in mind that it is possible to encounter bugs.",
                @"Warning", MessageBoxButtons.OKCancel);
            if (res != DialogResult.OK)
            {
                Dispose();
                Application.Exit();
            }
#endif

            var mg = new ManagementObjectSearcher("Select * from Win32_Processor").Get()
                     .Cast <ManagementBaseObject>();
            _coreCount = mg.Sum(item => int.Parse(item["NumberOfCores"].ToString()));
            _cpuName   = (string)mg.First()["Name"];
            _cpuName   = _cpuName.Replace("AMD Eng Sample: ", "").Trim();

            InitDefaultForm();

            _presetFunctions = new Dictionary <string, Dictionary <string, Action> >
            {
                { "64", new Dictionary <string, Action>
                  {
                      { "High Multi-core", () =>
                        {
                            ApplyFreqLock(false);
                            ApplyVoltage((decimal)1.05, 12, 128);
                            ApplyFrequencyAllCoreSetting(3800);

                            ApplyEDCSetting(Convert.ToInt32(30), 0, 800);
                            ApplyTDCSetting(0, 0, 600);
                            ApplyPPTSetting(0, 0, 1500);
                        } },
                      { "Best of both", () =>
                        {
                            RevertVoltage();
                            if (_cpuName.StartsWith("2S1"))
                            {
                                ApplyVoltage((decimal)1.05, 12, 128);
                            }
                            ApplyFrequencyAllCoreSetting(3200);
                            ApplyFreqLock(true);

                            ApplyEDCSetting(Convert.ToInt32(600), 0, 800);
                            ApplyTDCSetting(Convert.ToInt32(0), 0, 600);
                            ApplyPPTSetting(Convert.ToInt32(0), 0, 1500);
                        } },
                      { "High Single-core", () =>
                        {
                            RevertVoltage();
                            if (_cpuName.StartsWith("2S1"))
                            {
                                ApplyVoltage((decimal)1.1, 12, 128);                         // ?
                            }
                            ApplyFrequencyAllCoreSetting(3400);
                            ApplyFreqLock(true);

                            ApplyEDCSetting(Convert.ToInt32(700), 0, 700);
                            ApplyTDCSetting(Convert.ToInt32(700), 0, 700);
                            ApplyPPTSetting(Convert.ToInt32(1500), 0, 1500);
                        } }
                  } },
                { "48", new Dictionary <string, Action>
                  {
                      { "High Multi-core", () =>
                        {
                            ApplyVoltage((decimal)1.05, 12, 128);
                            ApplyFrequencyAllCoreSetting(3800);
                            ApplyFreqLock(true);

                            ApplyEDCSetting(Convert.ToInt32(45), 0, 200);
                            ApplyTDCSetting(0, 0, 1);
                            ApplyPPTSetting(0, 0, 1);
                        } },
                      { "Best of both", () =>
                        {
                            ApplyFreqLock(false);
                            RevertVoltage();
                            if (_cpuName.StartsWith("2S1"))
                            {
                                ApplyVoltage((decimal)1.05, 12, 128);
                            }
                            ApplyFrequencyAllCoreSetting(3300);

                            ApplyEDCSetting(Convert.ToInt32(600), 0, 800);
                            ApplyTDCSetting(Convert.ToInt32(0), 0, 600);
                            ApplyPPTSetting(Convert.ToInt32(0), 0, 1500);
                        } },
                      { "High Single-core", () =>
                        {
                            ApplyFreqLock(false);
                            RevertVoltage();
                            if (_cpuName.StartsWith("2S1"))
                            {
                                ApplyVoltage((decimal)1.1, 12, 128);                         // ?
                            }
                            ApplyFrequencyAllCoreSetting(3500);

                            ApplyEDCSetting(Convert.ToInt32(700), 0, 700);
                            ApplyTDCSetting(Convert.ToInt32(700), 0, 700);
                            ApplyPPTSetting(Convert.ToInt32(1500), 0, 1500);
                        } }
                  } },
                { "32", new Dictionary <string, Action>
                  {
                      { "High Multi-core", () =>
                        {
                            RevertVoltage();
                            if (_cpuName.StartsWith("2S1"))
                            {
                                ApplyVoltage((decimal)1.05, 12, 128);
                            }
                            ApplyFrequencyAllCoreSetting(3450);
                            ApplyFreqLock(true);

                            ApplyEDCSetting(Convert.ToInt32(600), 0, 700);
                            ApplyTDCSetting(Convert.ToInt32(600), 0, 700);
                            ApplyPPTSetting(Convert.ToInt32(1500), 0, 1500);
                        } },
                      { "Best of both", () =>
                        {
                            ApplyFreqLock(false);
                            RevertVoltage();
                            if (_cpuName.StartsWith("2S1"))
                            {
                                ApplyVoltage((decimal)1.05, 12, 128);
                            }
                            ApplyFrequencyAllCoreSetting(3300);

                            ApplyEDCSetting(Convert.ToInt32(600), 0, 800);
                            ApplyTDCSetting(Convert.ToInt32(0), 0, 600);
                            ApplyPPTSetting(Convert.ToInt32(0), 0, 1500);
                        } },
                      { "High Single-core", () =>
                        {
                            ApplyFreqLock(false);
                            RevertVoltage();
                            if (_cpuName.StartsWith("2S1"))
                            {
                                ApplyVoltage((decimal)1.1, 12, 128);                         // ?
                            }
                            ApplyFrequencyAllCoreSetting(3500);

                            ApplyEDCSetting(Convert.ToInt32(700), 0, 700);
                            ApplyTDCSetting(Convert.ToInt32(700), 0, 700);
                            ApplyPPTSetting(Convert.ToInt32(1500), 0, 1500);
                        } }
                  } }
            };
        }