Example #1
0
        public CStore GetOneStoreOrderHistory(string storeLoc)
        {
            using var context = new Project0databaseContext(_contextOptions);
            var dbStore = context.Stores.FirstOrDefault(x => x.Storeloc == storeLoc);

            if (dbStore == null)
            {
                return(null);
            }
            // store has no customer profile yet
            CStore seekStore = new CStore(dbStore.Storeloc, dbStore.Storephone);

            seekStore.CustomerDict = GetAllCustomersAtOneStore(storeLoc);

            foreach (var customer in seekStore.CustomerDict)
            {
                CCustomer cust = customer.Value;
                cust.OrderHistory = GetAllOrdersOfOneCustomer(cust.Customerid, seekStore, cust);
                foreach (var order in cust.OrderHistory)
                {
                    order.ProductList = GetAllProductsOfOneOrder(order.Orderid);
                    order.TotalCost   = seekStore.CalculateTotalPrice(order.ProductList);
                }
            }
            return(seekStore);
        }
Example #2
0
        public void DBAddAStore()
        {
            // setup
            var optionsBuilder = new DbContextOptionsBuilder <Project0databaseContext>();

            optionsBuilder.UseSqlServer(GetConnectionString());
            var    option   = optionsBuilder.Options;
            CStore newStore = new CStore("Mountain View 1", "6026626662");

            using (var context1 = new Project0databaseContext(option))
            {
                // using different context
                IStoreRepository repo = new StoreRepository(option);

                // action
                repo.AddOneStore(newStore);
            }

            // asert
            using var context2 = new Project0databaseContext(option);
            var dbStore = context2.Stores.First(x => x.Storeloc == "Mountain View 1");

            Assert.Equal(newStore.Storephone, dbStore.Storephone);
            Assert.Empty(dbStore.Storecustomers);
        }
Example #3
0
        private static void CustomerSetup(IStoreRepository repo, string storeLoc, CStore store)
        {
            Dictionary <string, CCustomer> customers = repo.GetAllCustomersAtOneStore(storeLoc);

            store.CustomerDict = customers;
            Console.WriteLine("Initial customer profile set up done");
        }
Example #4
0
        public void SearchCustomerByNameShouldReturnProfile()
        {
            // arrange
            List <CProduct> supply = new List <CProduct>
            {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 4),
                new CProduct("222", "orange", "Produce", 0.88, 4)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");

            COrder order = new COrder(store, customer, DateTime.Today, 100, p);

            customer.PlaceOrder(store, order);
            ISearch searchTool = new SimpleSearch();
            // act
            string customerid;
            bool   result = searchTool.SearchByName(store, "John", "Smith", out customerid);


            // assert
            Assert.True(result);
        }
Example #5
0
        public void ResupplyAndReorderReadAndWrite()
        {
            string          path    = "../../../SimplyWriteData.json";
            JsonFilePersist persist = new JsonFilePersist(path);
            CStore          store   = persist.ReadStoreData();

            List <CProduct> supply = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10),
                new CProduct("333", "Rocket", "Transport", 1000000, 15)
            };

            store.AddProducts(supply);
            CCustomer       customer = new CCustomer("127137147", "Adam", "Savage", "4801111111");
            List <CProduct> p        = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 1),
                new CProduct("222", "orange", "Produce", 0.88, 1)
            };
            COrder order = new COrder(store, customer, DateTime.Today, 100, p);

            customer.PlaceOrder(store, order);

            persist.WriteStoreData(store);
            foreach (var pair in store.Inventory)
            {
                Assert.Equal(15, pair.Value.Quantity);
            }
        }
        public void CustomerWithoutProfileFailedToPlaceAnOrder()
        {
            List <CProduct> supply = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 20),
                new CProduct("222", "orange", "Produce", 0.88, 20)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");
            COrder    order    = new COrder(store, customer, DateTime.Today, 100, p);

            customer.PlaceOrder(store, order);

            // inventory should not be updated 10-20<0 => 10
            foreach (var item in store.Inventory)
            {
                Assert.Equal(10, item.Value.Quantity);
            }

            // customer does not have an existing profile
            // a failed order doesn not create a new user profile
            // userDict should be empty
            // .Equal 0 does not check a collection size
            Assert.Empty(store.CustomerDict);
        }
        public void CustomerWithProfileFailedToPlaceAnOrder()
        {
            List <CProduct> supply = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 20),
                new CProduct("222", "orange", "Produce", 0.88, 20)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");
            COrder    order    = new COrder(store, customer, DateTime.Today, 100, p);

            // customer has an existing profile
            store.AddCustomer(customer);
            customer.PlaceOrder(store, order);

            // inventory should not be updated 10-20<0 => 10
            foreach (var item in store.Inventory)
            {
                Assert.Equal(10, item.Value.Quantity);
            }

            // userDict should have customer file, but with no order history
            Assert.Empty(store.CustomerDict["123123121"].OrderHistory);
        }
Example #8
0
        public List <COrder> GetAllOrdersOfOneCustomer(string customerid, CStore store, CCustomer customer)
        {
            using var context = new Project0databaseContext(_contextOptions);
            var dbCustomer = context.Customers.Include(x => x.Orderrs).FirstOrDefault(x => x.Customerid == customerid);

            if (dbCustomer == null)
            {
                return(null);
            }
            List <COrder> orders = new List <COrder>();

            if (dbCustomer.Orderrs == null)
            {
                return(null);
            }

            foreach (var order in dbCustomer.Orderrs)
            {
                // these orders have no product list
                // total cost not yet set
                COrder o = new COrder(order.Orderid, store, customer, order.Orderedtime, order.Totalcost);
                orders.Add(o);
            }

            return(orders);
        }
Example #9
0
        public List <COrder> GetOneCustomerOrderHistory(CCustomer customer, CStore store)
        {
            using var context = new Project0databaseContext(_contextOptions);
            var customerExist = context.Storecustomers.FirstOrDefault(x => x.Storeloc == store.Storeloc && x.Customerid == customer.Customerid);

            if (customerExist == null)
            {
                return(null);
            }

            List <COrder> OrderHistory = GetAllOrdersOfOneCustomer(customer.Customerid, store, customer);

            // has no order
            if (OrderHistory == null)
            {
                return(null);
            }

            foreach (var order in OrderHistory)
            {
                order.ProductList = GetAllProductsOfOneOrder(order.Orderid);
                order.TotalCost   = store.CalculateTotalPrice(order.ProductList);
            }
            return(OrderHistory);
        }
Example #10
0
        // helper classes refactored
        private static void InventorySetup(IStoreRepository repo, string storeLoc, CStore store)
        {
            List <CProduct> inventory = repo.GetInventoryOfAStore(storeLoc);

            store.CleanInventory();
            store.AddProducts(inventory);
            Console.WriteLine("Initial inventory set up done");
        }
        public void CreateACustomer()
        {
            CStore    store    = new CStore("Phoenix101");
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");

            Assert.Equal("123123121", customer.Customerid);
            Assert.Equal("John", customer.FirstName);
            Assert.Equal("Smith", customer.LastName);
            Assert.Equal("6021111111", customer.PhoneNumber);
        }
Example #12
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
#if LTV20_CONFIG
            _settingsLocation = @"SOFTWARE\LEAD Technologies, Inc.\20\CSharp_DicomSTR20";
#elif LTV19_CONFIG
            _settingsLocation = @"SOFTWARE\LEAD Technologies, Inc.\19\CSharp_DicomSTR19";
#elif LTV18_CONFIG
            _settingsLocation = @"SOFTWARE\LEAD Technologies, Inc.\18\CSharp_DicomSTR18";
#elif LTV175_CONFIG
            _settingsLocation = @"SOFTWARE\LEAD Technologies, Inc.\17.5\CSharp_DicomSTR17.5";
#elif LTV17_CONFIG
            _settingsLocation = @"SOFTWARE\LEAD Technologies, Inc.\17\CSharp_DicomSTR17";
#elif LTV16_CONFIG
            _settingsLocation = @"SOFTWARE\LEAD Technologies, Inc.\16\CSharp_DicomSTR16";
#else
            _settingsLocation = @"SOFTWARE\LEAD Technologies, Inc.\15\CSharp_DicomSTR15";
#endif


            LoadSettings();
            cstore = null;
            CreateCStoreObject(_useTls);
            if (cstore != null)
            {
                cstore.PresentationContextType = _presentationContextType;
                cstore.Compression             = _cstoreCompressionType;
            }

            using (DicomDataSet dcm = new DicomDataSet())
            {
                if (dcm == null)
                {
                    MessageBox.Show("Can't create dicom object. Quitting app.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                    return;
                }
            }

            using (DicomDataSet dcmDir = new DicomDataSet())
            {
                if (dcmDir == null)
                {
                    MessageBox.Show("Can't create dicom object. Quitting app.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                    return;
                }
            }

            panel2.Height = Convert.ToInt32(this.ClientSize.Height * 0.50);

            UpdateCStoreOptions();

            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
        }
Example #13
0
        public void SimplyReadData()
        {
            string          path    = "../../../SimplyWriteData.json";
            JsonFilePersist persist = new JsonFilePersist(path);
            CStore          store   = persist.ReadStoreData();

            foreach (var product in store.CustomerDict["123123121"].OrderHistory[0].ProductList)
            {
                Assert.Equal(4, product.Quantity);
            }
        }
Example #14
0
        // add methods
        public void AddOneStore(CStore store)
        {
            using var context = new Project0databaseContext(_contextOptions);
            var newStore = new Store
            {
                Storeloc   = store.Storeloc,
                Storephone = store.Storephone
            };

            context.Stores.Add(newStore);
            context.SaveChanges();
        }
Example #15
0
        public Page6(ref Globals pGlobals)
        {
            InitializeComponent();

            _globals = pGlobals;


            cstore = new CStore();

            cstore.ImplementationClass       = CONFIGURATION_IMPLEMENTATIONCLASS;
            cstore.ImplementationVersionName = CONFIGURATION_IMPLEMENTATIONVERSIONNAME;
            cstore.ProtocolVersion           = CONFIGURATION_PROTOCOLVERSION;
            cstore.Status += new StatusEventHandler(cstore_Status);
        }
Example #16
0
        public void CreateAStore()
        {
            List <CProduct> supply = new List <CProduct>
            {
                new CProduct("111", "Banana", "Produce", 0.5, 10), new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            CStore store = new CStore("Phoenix101", "606", supply);

            Assert.Equal("Phoenix101", store.Storeloc);
            foreach (var product in supply)
            {
                Assert.Equal(product.Quantity, store.Inventory[product.UniqueID].Quantity);
            }
        }
Example #17
0
        // M V C design
        // Get methods
        // store level
        public CStore GetOneStore(string storeLoc)
        {
            using var context = new Project0databaseContext(_contextOptions);
            var dbStore = context.Stores.FirstOrDefault(x => x.Storeloc == storeLoc);

            if (dbStore == null)
            {
                return(null);
            }
            // store has no customer profile yet
            CStore domainStore = new CStore(dbStore.Storeloc, dbStore.Storephone, dbStore.Zipcode);

            return(domainStore);
        }
 public bool SearchByNameAndPhone(CStore store, CCustomer customer, out string customerid)
 {
     foreach (var pair in store.CustomerDict)
     {
         CCustomer cust = pair.Value;
         if (cust.FirstName == customer.FirstName && cust.LastName == customer.LastName && cust.PhoneNumber == customer.PhoneNumber)
         {
             customerid = pair.Key;
             return(true);
         }
     }
     customerid = "";
     return(false);
 }
 /// <summary>
 /// simple approach to search by name, returns bool and customerid
 /// </summary>
 public bool SearchByName(CStore store, string firstname, string lastname, out string customerid)
 {
     foreach (var pair in store.CustomerDict)
     {
         CCustomer customer = pair.Value;
         if (firstname == customer.FirstName && lastname == customer.LastName)
         {
             customerid = pair.Key;
             return(true);
         }
     }
     customerid = "";
     return(false);
 }
Example #20
0
        // Multi-purpsoe
        public void CustomerPlaceOneOrder(COrder order, CStore store, double totalCost)
        {
            using var context = new Project0databaseContext(_contextOptions);
            // update order
            var newOrder = new Orderr
            {
                Orderid     = order.Orderid,
                Storeloc    = order.StoreLocation.Storeloc,
                Customerid  = order.Customer.Customerid,
                Orderedtime = DateTime.Now,
                Totalcost   = totalCost
            };

            context.Orderrs.Add(newOrder);
            context.SaveChanges();

            // update Orderproduct
            foreach (var product in order.ProductList)
            {
                var newOP = new Orderproduct
                {
                    Orderid   = order.Orderid,
                    Productid = product.UniqueID,
                    Quantity  = product.Quantity
                };
                context.Orderproducts.Add(newOP);
            }
            context.SaveChanges();

            var dbStore = context.Stores.Include(x => x.Inventories)
                          .FirstOrDefault(x => x.Storeloc == order.StoreLocation.Storeloc);

            // if (dbStore == null) return null;
            // update inventory quantity
            foreach (var product in order.ProductList)
            {
                foreach (var dbProd in dbStore.Inventories)
                {
                    if (product.UniqueID == dbProd.Productid)
                    {
                        dbProd.Quantity = store.Inventory[product.UniqueID].Quantity;
                    }
                }
            }
            context.SaveChanges();
        }
Example #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnLogin.CausesValidation = false;

                int    iStoreID = 0;
                string strID    = Request.QueryString["id"];
                if (strID == null)
                {
                    iStoreID = ApplicationSession.StoreID;
                }
                else
                {
                    bool isNumeric = int.TryParse(strID, out int iID);
                    if (isNumeric)
                    {
                        iStoreID = iID;
                    }
                }

                if (iStoreID == 0)
                {
                    iStoreID = CMain.STOREID;
                }

                CStore store = CMain.GetStoreRecord(iStoreID);
                if (store.IsEmpty())
                {
                    MessageBox.Show("Store Record is not found");
                }
                else
                {
                    ApplicationSession.DBName  = store.DBName;
                    ApplicationSession.StoreID = iStoreID;
                    ApplicationSession.QRcode  = "";
                    btnLogin.CausesValidation  = true;
                }

                string sEmail = Request.QueryString["email"];
                //txtUserID.Text = (sEmail == null) ? txtUserID.Text = "" : txtUserID.Text = sEmail;
                //txtPassword.Text = "";
            }

            //lblMessage.Text = "";
        }
Example #22
0
        // helpers
        public List <CStore> GetAllStores()
        {
            using var context = new Project0databaseContext(_contextOptions);
            var dbStores = context.Stores.ToList();

            if (dbStores == null)
            {
                return(null);
            }
            List <CStore> stores = new List <CStore>();

            foreach (var store in dbStores)
            {
                CStore s = new CStore(store.Storeloc, store.Storephone);
                stores.Add(s);
            }
            return(stores);
        }
        public ActionResult CheckOrder()
        {
            string    email    = TempData.Peek("User").ToString();
            CCustomer customer = _storeRepo.GetOneCustomerByEmail(email);
            string    storeLoc = TempData.Peek("storeLoc").ToString();
            CStore    store    = _storeRepo.GetOneStore(storeLoc);

            // collection information about this customer
            var OrderHistory = _storeRepo.GetOneCustomerOrderHistory(customer, store);

            if (OrderHistory == null)
            {
                return(View(new List <OrderViewModel>()));
            }
            var viewOrder = ViewModelMapper.MapOrders(OrderHistory);

            return(View(viewOrder));
        }
Example #24
0
        public void DisplayOneOrderPrintOnConsole()
        {
            IDisplay        dis    = new SimpleDisplay();
            List <CProduct> supply = new List <CProduct>
            {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 4),
                new CProduct("222", "orange", "Produce", 0.88, 4)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");
            COrder    order    = new COrder(store, customer, DateTime.Today, 100, p);

            dis.DisplayOneOrder(order);
            Assert.True(true);
        }
Example #25
0
        // GET: OrderController/Details/5
        public ActionResult Details(string id)
        {
            // customer id passed in
            string    storeLoc = TempData.Peek("adminLoc").ToString();
            CStore    store    = _storeRepo.GetOneStore(storeLoc);
            CCustomer customer = _storeRepo.GetOneCustomer(id);

            var orders    = _storeRepo.GetAllOrdersOfOneCustomer(id, store, customer);
            var viewOrder = orders.Select(x => new OrderViewModel
            {
                Orderid     = x.Orderid,
                StoreLoc    = x.StoreLocation.Storeloc,
                Customerid  = x.Customer.Customerid,
                OrderedTime = x.OrderedTime,
                TotalCost   = x.TotalCost,
            });

            return(View(viewOrder));
        }
Example #26
0
        public void CreateAOrder()
        {
            List <CProduct> supply = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 4),
                new CProduct("222", "orange", "Produce", 0.88, 4)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");
            COrder    order    = new COrder(store, customer, DateTime.Today, 100, p);

            Assert.Equal("Phoenix101", order.StoreLocation.Storeloc);
            Assert.Equal("123123121", order.Customer.Customerid);
            Assert.Equal(DateTime.Today, order.OrderedTime);
            Assert.Equal(p, order.ProductList);
        }
Example #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //ApplicationSession.SalesMaster.CollectionSalesDetail() = new SalesDetailCollection();
                CStore store = CMain.GetStoreRecord(ApplicationSession.StoreID);
                if (store.IsEmpty())
                {
                    MessageBox.Show("Fail to retrieve Store Record");
                }
                else
                {
                    MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName);

                    List <COutlet> lst = store.ListOfOutlets(conn);
                    lvwOutlet.DataSource = lst;
                    lvwOutlet.DataBind();
                }
            }
        }
Example #28
0
        public void StoreAddACustomer()
        {
            List <CProduct> supply = new List <CProduct>
            {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };

            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");

            store.AddCustomer(customer);
            foreach (var pair in store.CustomerDict)
            {
                if (pair.Key == customer.Customerid)
                {
                    Assert.True(true);
                }
            }
        }
        public void CustomerPlacedASuccessfulOrder()
        {
            List <CProduct> supply = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 4),
                new CProduct("222", "orange", "Produce", 0.88, 4)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");
            COrder    order    = new COrder(store, customer, DateTime.Today, 100, p);

            customer.PlaceOrder(store, order);
            // inventory should be updated 10-4=6
            foreach (var item in store.Inventory)
            {
                Assert.Equal(6, item.Value.Quantity);
            }
        }
        public void CustomerPurchasedTooMany()
        {
            List <CProduct> supply = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 10),
                new CProduct("222", "orange", "Produce", 0.88, 10)
            };
            List <CProduct> p = new List <CProduct> {
                new CProduct("111", "Banana", "Produce", 0.5, 2000),
                new CProduct("222", "orange", "Produce", 0.88, 2000)
            };
            CStore    store    = new CStore("Phoenix101", "606", supply);
            CCustomer customer = new CCustomer("123123121", "John", "Smith", "6021111111");

            try
            {
                COrder order = new COrder(store, customer, DateTime.Today, 100, p);
            }
            catch (ArgumentException e)
            {
                Assert.Equal("This order contains high quantity of products", e.ToString());
            }
        }
Example #31
0
 void AutoAddFiles2StoreWhenFinish(CStore cstore)
 {
     try
     {
         if (cstore == null) return;
         cstore.Files.Clear();
         foreach (Control  ctrl in pnlScheduled.Controls)
         {
             ScheduledControl _ScheduledControl = ctrl as ScheduledControl;
             if (_ScheduledControl.Status == 1 && File.Exists(_ScheduledControl.DcmfileName))
             {
                 cstore.Files.Add(_ScheduledControl.DcmfileName);
                 AppLogger.LogAction.AddLog2List(lstFPD560,"CStore Added file:" + _ScheduledControl.DcmfileName);
             }
         }
     }
     catch
     {
     }
 }
Example #32
0
        void AutoSend2miPACS()
        {
            try
            {               
                //Save to Server
                DataTable dtServerList = GetServerList();
                if (dtServerList.Rows.Count <= 0)
                {
                    return;
                }
                string ErrorMsg = "";
                string SuccessConnect = "";
                foreach (DataRow dr1 in dtServerList.Rows)
                {
                    try
                    {
                        if (Convert.ToInt32(dr1["isActive"]) == 1)
                        {
                            CStore cstore = new CStore();
                            CreateCStoreObject(cstore, false);
                            string LocalAddress =Utility.sDbnull( dr1["LocalAddress"].ToString(),"");
                            string LocalAETitle = dr1["CallingAETitle"].ToString();
                            string RemoteAETitle = dr1["CalledAETitle"].ToString();
                            string RemoteHost = dr1["IPAddress"].ToString();
                            int Port = Utility.Int32Dbnull(dr1["Port"],104);
                            int LocalPort = Utility.Int32Dbnull(dr1["LocalPort"],0);

                            Leadtools.Commands.DicomDemos.DicomServer server = new Leadtools.Commands.DicomDemos.DicomServer();
                            server.LocalAddress = LocalAddress;
                            server.LocalPort = LocalPort;
                            server.AETitle = RemoteAETitle;
                            server.Port = Port;
                            server.Address = IPAddress.Parse(RemoteHost);
                            server.IpType = DicomNetIpTypeFlags.Ipv4;
                            server.Timeout = 60;
                            cstore.Compression = DicomImageCompressionType.None;
                            cstore.PresentationContextType = 0;
                            AutoAddFiles2StoreWhenFinish(cstore);
                            pnlScheduled.Controls.Clear();
                            //AddFiles4Store(_CurrCell.Tag.ToString());
                            string errMsg="";
                            cstore.Store(server, RemoteAETitle, ref errMsg);
                           
                        }

                    }
                    catch
                    {
                    }
                }
                //Update Datasource and reg Status

                if (new RegController().UpdateStatus(currREGID, 3) == ActionResult.Success)
                {
                    DataRow[] arrDr = m_dtStudyListDataSource.Select("REG_ID=" + currREGID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                            arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource.Select("REG_ID=" + currREGID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                        arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource_Suspending.Select("REG_ID=" + currREGID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                        arrDr[0]["REGSTATUS"] = 3;
                    }
                    m_dtStudyListDataSource.AcceptChanges();
                    m_dtWLDataSource.AcceptChanges();
                    m_dtWLDataSource_Suspending.AcceptChanges();
                }

            }
            catch
            {
            }
        }
Example #33
0
        void CreateCStoreObject(CStore cstore,bool secure)
        {
            try
            {
                if (cstore != null)
                {
                    cstore.Dispose();
                    cstore = null;
                }
                if (secure)
                {
                    string clientPEM = Application.StartupPath + @"\client.pem";
                    string privateKeyPassword = "******";

                    cstore = new CStore(clientPEM, DicomTlsCipherSuiteType.DheRsaWith3DesEdeCbcSha, DicomTlsCertificateType.Pem, privateKeyPassword);
                }
                else
                {
                    cstore = new CStore();
                }

                cstore.ImplementationClass = CONFIGURATION_IMPLEMENTATIONCLASS;
                cstore.ImplementationVersionName = CONFIGURATION_IMPLEMENTATIONVERSIONNAME;
                cstore.ProtocolVersion = CONFIGURATION_PROTOCOLVERSION;
                cstore.Status += new StatusEventHandler(cstore_Status);
                cstore.ProgressFiles += new ProgressFilesEventHandler(cstore_ProgressFiles);
            }
            catch
            {
            }
        }
Example #34
0
 void AddFiles4Store(CStore cstore)
 {
     try
     {
         if (cstore == null) return;
         cstore.Files.Clear();
         foreach (OScheduledControl _OScheduledControl in pnlThumbnailResult.Controls)
         {
             if (_OScheduledControl.isPressed && _OScheduledControl.Status == 1 && File.Exists(_OScheduledControl.DcmfileName))
             {
                 cstore.Files.Add(_OScheduledControl.DcmfileName);
             }
         }
     }
     catch
     {
     }
 }
Example #35
0
 void AddFiles4Store(CStore cstore, string fileName)
 {
     try
     {
         if (cstore == null) return;
         cstore.Files.Add(fileName);
     }
     catch
     {
     }
 }
Example #36
0
        void S2S()
        {


            try
            {
                isS2Sing = true;
                Utility.SetMsg(lblS2Smsg, "", false);
                //cstore = null;
                
                

                if (grdStudyList.RowCount <= 0 || grdStudyList.SelectedRows == null) return;
                //Save to Server
                DataTable dtServerList = GetServerList();
                if (dtServerList.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Chưa tồn tại danh sách các PACS Server nên bạn không thể thực hiện thao tác gửi ảnh tới Server.\nBạn hãy vào mục cấu hình và khai báo các Servers.", "Thông báo");
                    return;
                }
                DataRow dr = ((DataRowView)grdStudyList.CurrentRow.DataBoundItem).Row;
                long RegID = Convert.ToInt64(dr["Reg_ID"]);
                //string pcode = Utility.sDbnull(dr["Patient_Code"]);

                // string pname = Utility.sDbnull(dr["Patient_Name"]);
                //DateTime BirthDate = Convert.ToDateTime(dr["BIRTH_DATE"]);
                //string age= (DateTime.Now.Year - Convert.ToDateTime(dr["BIRTH_DATE"]).Year).ToString();

                //SubDirPatient = pcode + "_" + Bodau(pname).Replace(age, "").Trim().Replace(" ", "_").Trim() + "_" + age;
                //ArrayList _arrImg = GetArrImg(RegID);
                //if (_arrImg == null || _arrImg.Count <= 0)
                //{
                //    Utility.ShowMsg("Các file ảnh ứng với Bệnh nhân đang chọn không tồn tại. Đề nghị bạn kiểm tra lại thư mục lưu ảnh\n" + txtImgDir.Text.Trim(), "Thông báo");
                //    return;
                //}
                //StorageScu _storageScu = new StorageScu();

                //string FileErr = "";
                //foreach (string s in _arrImg)
                //{
                //    if (!_storageScu.AddFileToSend(s)) FileErr += s + ",";
                //}
                //if (FileErr.Trim() != "")
                //{
                //    Utility.ShowMsg("Các file sau không xác định được SopClassUid nên sẽ không thể gửi được tới Server. Bạn cần copy thủ công bằng tay các file này\n" + FileErr.Substring(0, FileErr.Length - 1) + "\nHãy nhấn OK để tiếp tục gửi các file hợp lệ", "Thông báo");
                //}

                string ErrorMsg = "";
                string SuccessConnect = "";
                foreach (DataRow dr1 in dtServerList.Rows)
                {
                    try
                    {
                        if (Convert.ToInt32(dr1["isActive"]) == 1)
                        {
                            CStore cstore = new CStore();
                            CreateCStoreObject(cstore,false);
                            string LocalAETitle = dr1["CallingAETitle"].ToString();
                            string LocalAddress = dr1["LocalAddress"].ToString();
                            string RemoteAETitle = dr1["CalledAETitle"].ToString();
                            string RemoteHost = dr1["IPAddress"].ToString();
                            int Port = Convert.ToInt32(dr1["Port"]);
                            int LocalPort = Convert.ToInt32(dr1["LocalPort"]);

                            DicomServer server = new DicomServer();
                            server.AETitle = RemoteAETitle;
                            server.LocalAddress = LocalAddress;
                            server.LocalPort = LocalPort;
                            server.Port = Port;
                            server.Address = IPAddress.Parse(RemoteHost);
                            server.IpType = DicomNetIpTypeFlags.Ipv4;
                            server.Timeout = 60;
                            cstore.Compression = DicomImageCompressionType.None;
                            cstore.PresentationContextType = 0;
                            AddFiles4Store(cstore);
                        
                            cstore.Store(server, RemoteAETitle, ref ErrorMsg);
                            //_storageScu.Send(LocalAETitle, RemoteAETitle, RemoteHost, Port);
                            //if (_storageScu._dicomClient == null || !_storageScu._dicomClient.ConnectSuccess)
                            //{
                            //    ErrorMsg = "Không thể kết nối tới Server " + RemoteHost + "(Port=" + Port.ToString() + ",RemoteAETitle=" + RemoteAETitle + ",LocalAETitle=" + LocalAETitle + ")";
                            //}
                            //else
                            //{
                            //    SuccessConnect += RemoteHost + ",";
                            //}
                        }
                        //if (SuccessConnect.Trim() != "")
                        //{
                        //    SuccessConnect = SuccessConnect.Substring(0, SuccessConnect.Length - 1);
                        //    SuccessConnect += "\n" + ErrorMsg;
                        //    Utility.ShowMsg("Đã lưu dữ liệu ảnh thành công tới Server: " + SuccessConnect, "Thông báo");
                        //}
                        //else
                        //{
                        //    if (ErrorMsg.Trim() != "") Utility.ShowMsg(ErrorMsg, "Thông báo");
                        //}


                    }

                    catch
                    {
                    }
                }
                //Update Datasource and reg Status

                if (new RegController().UpdateStatus(RegID, 3) == ActionResult.Success)
                {
                    DataRow[] arrDr = m_dtStudyListDataSource.Select("REG_ID=" + RegID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                        arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource.Select("REG_ID=" + RegID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                        arrDr[0]["REGSTATUS"] = 3;
                    }
                    arrDr = m_dtWLDataSource_Suspending.Select("REG_ID=" + RegID);
                    if (arrDr.GetLength(0) > 0)
                    {
                        if (arrDr[0]["REGSTATUS"].ToString() != "2")
                        arrDr[0]["REGSTATUS"] = 3;
                    }
                    m_dtStudyListDataSource.AcceptChanges();
                    m_dtWLDataSource.AcceptChanges();
                    m_dtWLDataSource_Suspending.AcceptChanges();
                    if (ErrorMsg.Trim() == "") Utility.SetMsg(lblS2Smsg, "Đã gửi dữ liệu thành công!", false);
                    else Utility.SetMsg(lblS2Smsg, ErrorMsg, true);
                }

            }
            catch
            {
            }
            finally
            {
                isS2Sing = false;
            }
        }