예제 #1
0
        /// <summary>
        /// 获取插件包的信息
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static IEnumerable <PluginPackAttribute> GetPluginPackInfo(string fileName)
        {
            var tempDir = String.Concat(AppDomain.CurrentDomain, PluginConfig.PLUGIN_TMP_DIRECTORY, "tmp/");

            if (Directory.Exists(tempDir))
            {
                Directory.Delete(tempDir, true);
            }
            Directory.CreateDirectory(tempDir).Create();

            var dir = new DirectoryInfo(tempDir);

            ZipUtility.UncompressFile(tempDir, fileName, false);

            Assembly ass;

            string[] multExt = PluginConfig.GetFilePartterns();
            foreach (String ext in multExt)
            {
                var files = dir.GetFiles(ext);
                foreach (FileInfo f in files)
                {
                    ass = Assembly.Load(File.ReadAllBytes(f.FullName));

                    var attbs = ass.GetCustomAttributes(typeof(PluginPackAttribute), false);
                    foreach (object attb in attbs)
                    {
                        if (attb is PluginPackAttribute)
                        {
                            yield return((PluginPackAttribute)attb);
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 安装/升级插件
        /// </summary>
        /// <param name="url"></param>
        /// <param name="handler"></param>
        /// <returns></returns>
        public static bool InstallPlugin(string url, PluginHandler <PluginPackAttribute> handler)
        {
            var    installResult = false;
            string appDirectory  = AppDomain.CurrentDomain.BaseDirectory;
            var    pluginPath    = String.Concat(
                appDirectory,
                PluginConfig.PLUGIN_DIRECTORY);

            var tempDir  = String.Concat(appDirectory, PluginConfig.PLUGIN_TMP_DIRECTORY, "plugin/");
            var fileName = tempDir + "dl_pack_" + String.Empty.RandomLetters(16) + ".zip";

            if (Directory.Exists(tempDir))
            {
                Directory.Delete(tempDir, true);
            }
            Directory.CreateDirectory(tempDir).Create();

            var dir = new DirectoryInfo(tempDir);

            var data = WebClient.DownloadFile(url, null);

            using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                fs.Write(data, 0, data.Length);
                fs.Flush();
                fs.Dispose();
            }

            IList <PluginPackAttribute> pluginAttrs = new List <PluginPackAttribute>(GetPluginPackInfo(fileName));

            if (pluginAttrs.Count != 0)
            {
                ZipUtility.UncompressFile(pluginPath, fileName, false);
                foreach (FileInfo file in dir.GetFiles("*.dll"))
                {
                    File.Delete(pluginPath + file.Name);
                    file.MoveTo(pluginPath + file.Name);
                }

                if (handler != null)
                {
                    var result = false;
                    foreach (PluginPackAttribute attr in pluginAttrs)
                    {
                        handler(attr, ref result);
                    }
                }

                installResult = true;
            }

            Directory.Delete(tempDir, true);

            return(installResult);
        }
예제 #3
0
        private void btnSmmMakbuzIndir_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckConnParam() || !TextBoxFatura())
                {
                    throw new CheckConnParamException(
                              "TCKN / VKN, Şube , WS Kullanıcı Adı, WS Şifre ve İndirilecek Faturanın UUID veya ID alanları boş olamaz!");
                }

                SmmWebService       eSmm     = new SmmWebService();
                var                 result   = eSmm.SmmPDFIndir(SetValue(), CheckedSSL());
                var                 pdf      = ZipUtility.UncompressFile(result[0].DocData);
                FolderBrowserDialog fbDialog = new FolderBrowserDialog();
                fbDialog.Description = "Lütfen kaydetmek istediğiniz dizini seçiniz...";
                fbDialog.RootFolder  = Environment.SpecialFolder.Desktop;
                if (fbDialog.ShowDialog() == DialogResult.OK)
                {
                    //dialog ile kullanıcıya seçtirilen dizine fatura UUID si ile dosya ismini set ederek kayıt işlemi yapıyoruz.
                    File.WriteAllBytes(fbDialog.SelectedPath + "\\" + txtFaturaUUID.Text + ".pdf", pdf);

                    MessageBox.Show("Serbest Makbuz PDF İndirme Başarılı", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (CheckConnParamException ex)
            {
                MessageBox.Show(ex.Message, "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (FaultException <ProcessingFault> ex)
            {
                MessageBox.Show(ex.Detail.Message, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FaultException ex)
            {
                MessageBox.Show(ex.Message, "FaultException", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #4
0
        /// <summary>
        /// Grid üzerindeki irsaliyelerin XML(UBL) formatında masaüstünde oluşturulan bir klasöre kaydını yapar
        /// </summary>
        /// <returns>e-İrsaliye UBL Kaydetme</returns>
        private void btnIrsaliyeUblIndir_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckConnParam())
                {
                    throw new CheckConnParamException("TCKN/VKN, Gönderici Birim Etiketi, Posta Kutusu Etiketi, WS Kullanıcı Adı ve WS Şifre alanları boş bırakılamaz!");
                }


                List <string> allUUID  = new List <string>();
                var           despatch = new DespatchWebService();

                foreach (DataGridViewRow item in grdListIrsaliye.Rows)
                {
                    allUUID.Add(item.Cells[0].Value.ToString());
                }

                if (allUUID.Count != 0)
                {
                    string recordPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + String.Format("\\{0}-UBL", RequestModel.DocType);
                    if (File.Exists(recordPath) == false)
                    {
                        Directory.CreateDirectory(recordPath);
                    }


                    var splitUUIDArray = allUUID.Split(20);

                    foreach (var UUIDList in splitUUIDArray)
                    {
                        var result = despatch.IrsaliyeUBLIndir(SetTextModel(), UUIDList.ToArray(), CheckedSSL(), RequestModel).Response;

                        for (int i = 0; i < result.Count(); i++)
                        {
                            File.WriteAllBytes(Path.Combine(recordPath, UUIDList[i] + ".xml"), ZipUtility.UncompressFile(result[i].DocData));
                        }
                    }

                    MessageBox.Show("UBL İndirme Başarılı", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("İndirilecek Bir UBL Bulunmamaktadır.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            catch (UUIDNullException ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            catch (CheckConnParamException ex)
            {
                MessageBox.Show(ex.Message, "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            catch (FaultException <ProcessingFault> ex)
            {
                MessageBox.Show(ex.Detail.Message, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FaultException ex)
            {
                MessageBox.Show(ex.Message, "FaultException", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #5
0
        /// <summary>
        /// TCKN/VKN parametresi ile sisteme kayıtlı  mükellefi sorgular
        /// </summary>
        /// <returns>TCKN/VKN ile Mükellef Sorgulama</returns>
        private void btnMukSorgu_Click(object sender, EventArgs e)
        {
            ClearText();

            try
            {
                if (!CheckConnParam())
                {
                    throw new CheckConnParamException("TCKN/VKN, Gönderici Birim Etiketi, Posta Kutusu Etiketi, WS Kullanıcı Adı ve WS Şifre alanları boş bırakılamaz!");
                }

                lblBaslik.Text = "Mükellef Sorgulanıyor";
                ButtonAktifPasif(false, false);
                grdListIrsaliye.DataSource = null;

                DespatchWebService despatch = new DespatchWebService();
                var result       = despatch.MukellefSorgula(SetTextModel(), CheckedSSL()).DocData;
                var zippedStream = new MemoryStream(result);
                using (var archive = new ZipArchive(zippedStream))
                {
                    foreach (var entry in archive.Entries)
                    {
                        var ms        = new MemoryStream();
                        var zipStream = entry.Open();
                        zipStream.CopyTo(ms);
                        XmlByte = ms.ToArray();
                    }
                }

                var fbDialog = new FolderBrowserDialog();
                fbDialog.Description = "Lütfen kaydetmek istediğiniz dizini seçiniz...";
                fbDialog.RootFolder  = Environment.SpecialFolder.Desktop;
                if (fbDialog.ShowDialog() == DialogResult.OK)
                {
                    //dialog ile kullanıcıya seçtirilen dizine irsaliye UUID si ile dosya ismini set ederek kayıt işlemi yapıyoruz.
                    File.WriteAllBytes(fbDialog.SelectedPath + "\\" + "mükellefListesi" + ".xml", ZipUtility.UncompressFile(result));
                    MessageBox.Show("Mükellef Listesi İndirme Başarılı", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                lblBaslik.Text             = "Mükellef Sorgulama";
                grdListIrsaliye.DataSource = JoinTable();
            }
            catch (CheckConnParamException ex)
            {
                MessageBox.Show(ex.Message, "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            catch (FaultException <ProcessingFault> ex)
            {
                MessageBox.Show(ex.Detail.Message, "ProcessingFault", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FaultException ex)
            {
                MessageBox.Show(ex.Message, "FaultException", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }