Example #1
0
 static void ImportDocuments(System.IO.DirectoryInfo directory, AMTANGEE.SDK.Documents.Category parentCat, AMTANGEE.Forms.ProgressForm pf)
 {
     AMTANGEE.SDK.Documents.Category docCat = null;
     foreach (AMTANGEE.SDK.Documents.Category c in parentCat.Children)
     {
         if (c.Name.ToUpper() == directory.Name.ToUpper())
         {
             docCat = c;
             break;
         }
     }
     if (docCat == null)
     {
         docCat      = new AMTANGEE.SDK.Documents.Category(parentCat);
         docCat.Name = directory.Name;
         docCat.Save();
     }
     System.IO.FileInfo[] files = directory.GetFiles();
     foreach (System.IO.FileInfo file in files)
     {
         pf.Caption = file.FullName;
         AMTANGEE.SDK.Documents.Document d = new AMTANGEE.SDK.Documents.Document(docCat);
         d.DateTime    = DateTime.Now;
         d.Description = file.Name;
         if (file.Extension.Trim().Length <= 5)
         {
             d.FileType = file.Extension;
         }
         else
         {
             d.FileType = file.Extension.Substring(0, 5);
         }
         d.LoadFromFile(file.FullName);
         d.Save();
         pf.Position++;
         Application.DoEvents();
     }
     System.IO.DirectoryInfo[] directories = directory.GetDirectories();
     foreach (System.IO.DirectoryInfo d in directories)
     {
         ImportDocuments(d, docCat, pf);
     }
 }
Example #2
0
        static void Do()
        {
            if (_param == null)
            {
                _param = "";
            }

            if (_param_2 == null)
            {
                _param_2 = "";
            }

            if (vTimer == null)
            {
                vCallback = new System.Threading.TimerCallback(TimerTick);
                vTimer    = new System.Threading.Timer(vCallback, null, 1000, 1000);
            }
            if (_param.Length > 0)
            {
                string parameter = _param;
                try
                {
                    if (!parameter.ToLower().StartsWith("amtangee://"))
                    {
                        if (_param2 != null && _param2.Length > 1 && parameter == "EML" && _param2[1].Trim().Length > 0)
                        {
                            if (!AMTANGEE.Remote.Tools.CheckForAMTANGEE())
                            {
                                return;
                            }
                            try
                            {
                                Guid guid = Guid.NewGuid();
                                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\AMTANGEE\\EMLViewer", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key.SetValue(guid.ToString() + "_File", _param2[1], Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue(guid.ToString() + "_User", System.Environment.UserName, Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue(guid.ToString() + "_Date", DateTime.Now.ToString(), Microsoft.Win32.RegistryValueKind.String);
                                AMTANGEE.SDK.Events.SendSDKEvent("SHOWEML:" + guid.ToString(), false);
                            }
                            catch
                            {
                            }
                        }

                        if (_param2 != null && _param2.Length > 1 && parameter == "OPENEML" && _param2[1].Trim().Length > 0)
                        {
                            if (!AMTANGEE.Remote.Tools.CheckForAMTANGEE())
                            {
                                return;
                            }
                            try
                            {
                                Guid guid = Guid.NewGuid();
                                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\AMTANGEE\\FileViewer", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key = key.CreateSubKey(guid.ToString(), RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key.SetValue("File", _param2[1], Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("User", System.Environment.UserName, Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Date", DateTime.Now.ToString(), Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Type", "EML", Microsoft.Win32.RegistryValueKind.String);
                                AMTANGEE.SDK.Events.Send(AMTANGEE.SDK.Global.CurrentUser, "*AMTANGEE.MODULES.MESSAGES.DLL:OPENEML:{" + guid.ToString().ToUpper() + "}", true);
                            }
                            catch
                            {
                            }
                        }

                        if (_param2 != null && _param2.Length > 1 && parameter == "OPENMSG" && _param2[1].Trim().Length > 0)
                        {
                            if (!AMTANGEE.Remote.Tools.CheckForAMTANGEE())
                            {
                                return;
                            }
                            try
                            {
                                Guid guid = Guid.NewGuid();
                                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\AMTANGEE\\FileViewer", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key = key.CreateSubKey(guid.ToString(), RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key.SetValue("File", _param2[1], Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("User", System.Environment.UserName, Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Date", DateTime.Now.ToString(), Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Type", "MSG", Microsoft.Win32.RegistryValueKind.String);
                                AMTANGEE.SDK.Events.Send(AMTANGEE.SDK.Global.CurrentUser, "*AMTANGEE.MODULES.MESSAGES.DLL:OPENMSG:{" + guid.ToString().ToUpper() + "}", true);
                            }
                            catch
                            {
                            }
                        }

                        if (_param2 != null && _param2.Length > 1 && parameter == "OPENVCS" && _param2[1].Trim().Length > 0)
                        {
                            if (!AMTANGEE.Remote.Tools.CheckForAMTANGEE())
                            {
                                return;
                            }
                            try
                            {
                                Guid guid = Guid.NewGuid();
                                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\AMTANGEE\\FileViewer", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key = key.CreateSubKey(guid.ToString(), RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key.SetValue("File", _param2[1], Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("User", System.Environment.UserName, Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Date", DateTime.Now.ToString(), Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Type", "VCS", Microsoft.Win32.RegistryValueKind.String);
                                AMTANGEE.SDK.Events.Send(AMTANGEE.SDK.Global.CurrentUser, "*AMTANGEE.MODULES.APPOINTMENTS.DLL:OPENVCS:{" + guid.ToString().ToUpper() + "}", true);
                            }
                            catch
                            {
                            }
                        }

                        if (_param2 != null && _param2.Length > 1 && parameter == "OPENICS" && _param2[1].Trim().Length > 0)
                        {
                            if (!AMTANGEE.Remote.Tools.CheckForAMTANGEE())
                            {
                                return;
                            }
                            try
                            {
                                Guid guid = Guid.NewGuid();
                                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\AMTANGEE\\FileViewer", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key = key.CreateSubKey(guid.ToString(), RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key.SetValue("File", _param2[1], Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("User", System.Environment.UserName, Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Date", DateTime.Now.ToString(), Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Type", "ICS", Microsoft.Win32.RegistryValueKind.String);
                                AMTANGEE.SDK.Events.Send(AMTANGEE.SDK.Global.CurrentUser, "*AMTANGEE.MODULES.APPOINTMENTS.DLL:OPENICS:{" + guid.ToString().ToUpper() + "}", true);
                            }
                            catch
                            {
                            }
                        }

                        if (_param2 != null && _param2.Length > 1 && parameter == "OPENVCF" && _param2[1].Trim().Length > 0)
                        {
                            if (!AMTANGEE.Remote.Tools.CheckForAMTANGEE())
                            {
                                return;
                            }
                            try
                            {
                                Guid guid = Guid.NewGuid();
                                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\AMTANGEE\\FileViewer", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key = key.CreateSubKey(guid.ToString(), RegistryKeyPermissionCheck.ReadWriteSubTree);
                                key.SetValue("File", _param2[1], Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("User", System.Environment.UserName, Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Date", DateTime.Now.ToString(), Microsoft.Win32.RegistryValueKind.String);
                                key.SetValue("Type", "VCF", Microsoft.Win32.RegistryValueKind.String);
                                AMTANGEE.SDK.Events.Send(AMTANGEE.SDK.Global.CurrentUser, "*AMTANGEE.MODULES.CONTACTS.DLL:OPENVCF:{" + guid.ToString().ToUpper() + "}", true);
                            }
                            catch
                            {
                            }
                        }


                        if (_param2 != null && _param2.Length == 1)
                        {
                            try
                            {
                                if (System.IO.File.Exists(_param2[0]))
                                {
                                    System.IO.FileInfo fi = new System.IO.FileInfo(_param2[0]);


                                    bool found = false;
                                    switch (fi.Extension.Replace(".", "").ToUpper())
                                    {
                                    case "EML":
                                        SetAssociation(".eml", "EML_File", System.IO.Path.Combine(AMTANGEE.SDK.Global.AMTANGEEDirectory, "FileViewer.exe"), "OPENEML", "4", "EML-Datei");
                                        found = true;
                                        break;

                                    case "MSG":
                                        SetAssociation(".msg", "MSG_File", System.IO.Path.Combine(AMTANGEE.SDK.Global.AMTANGEEDirectory, "FileViewer.exe"), "OPENMSG", "4", "MSG-Datei");
                                        found = true;
                                        break;

                                    case "VCF":
                                        SetAssociation(".vcf", "VCF_File", System.IO.Path.Combine(AMTANGEE.SDK.Global.AMTANGEEDirectory, "FileViewer.exe"), "OPENVCF", "5", "VCF-Datei");
                                        found = true;
                                        break;

                                    case "ICS":
                                        SetAssociation(".ics", "ICS_File", System.IO.Path.Combine(AMTANGEE.SDK.Global.AMTANGEEDirectory, "FileViewer.exe"), "OPENICS", "6", "ICS-Datei");
                                        found = true;
                                        break;

                                    case "VCS":
                                        SetAssociation(".vcs", "VCS_File", System.IO.Path.Combine(AMTANGEE.SDK.Global.AMTANGEEDirectory, "FileViewer.exe"), "OPENVCS", "6", "VCS-Datei");
                                        found = true;
                                        break;
                                    }

                                    if (found)
                                    {
                                        System.Diagnostics.Process.Start(_param2[0]);
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }

                        try
                        {
                            AMTANGEE.Forms.SelectCategoryForm scf = new AMTANGEE.Forms.SelectCategoryForm(AMTANGEE.Controls.CategoriesTree.Kinds.Documents, AMTANGEE.SDK.CategoryRights.Add, "Zielkategorie", "Ok");
                            try
                            {
                                foreach (string str in _param2)
                                {
                                    if (System.IO.Directory.GetDirectories(str).Length > 0)
                                    {
                                        AMTANGEE.SDK.Documents.Categories cats = new AMTANGEE.SDK.Documents.Categories();
                                        foreach (AMTANGEE.SDK.Documents.Category c in cats)
                                        {
                                            if (!c.HasRight(AMTANGEE.SDK.CategoryRights.CreateSubCategory))
                                            {
                                                scf.BlockCategory(c);
                                            }
                                        }
                                    }
                                }

                                if (scf.ShowDialog() == DialogResult.OK)
                                {
                                    AMTANGEE.SDK.Documents.Category docCat = (AMTANGEE.SDK.Documents.Category)scf.SelectedCategory;
                                    Environment.GetFolderPath(Environment.SpecialFolder.SendTo);
                                    AMTANGEE.Forms.ProgressForm pf = new AMTANGEE.Forms.ProgressForm();
                                    pf.Text          = "Dateien werden importiert...";
                                    pf.StartPosition = FormStartPosition.CenterScreen;
                                    pf.TopMost       = true;
                                    pf.Caption       = "";
                                    int allFiles = 0;
                                    System.IO.DirectoryInfo di = null;
                                    foreach (string p in _param2)
                                    {
                                        if (isDirectory(p))
                                        {
                                            allFiles += new System.IO.DirectoryInfo(p).GetFiles("*.*", System.IO.SearchOption.AllDirectories).Length;
                                        }
                                        else
                                        {
                                            allFiles++;
                                        }
                                    }

                                    pf.Maximum = allFiles;
                                    pf.Show();
                                    AMTANGEE.SDK.Documents.Documents.BeginUpdate();
                                    foreach (string p in _param2)
                                    {
                                        di = null;
                                        System.IO.FileInfo fi = null;
                                        if (isDirectory(p))
                                        {
                                            di = new System.IO.DirectoryInfo(p);
                                        }
                                        else
                                        {
                                            fi = new System.IO.FileInfo(p);
                                        }

                                        if (di != null)
                                        {
                                            ImportDocuments(di, docCat, pf);
                                        }

                                        if (fi != null)
                                        {
                                            pf.Caption = fi.FullName;
                                            AMTANGEE.SDK.Documents.Document d = new AMTANGEE.SDK.Documents.Document(docCat);
                                            d.DateTime    = DateTime.Now;
                                            d.Description = fi.Name;
                                            if (fi.Extension.Trim().Length <= 5)
                                            {
                                                d.FileType = fi.Extension;
                                            }
                                            else
                                            {
                                                d.FileType = fi.Extension.Substring(0, 5);
                                            }
                                            d.LoadFromFile(fi.FullName);
                                            d.Save();
                                            pf.Position++;
                                            Application.DoEvents();
                                        }
                                    }
                                    pf.Hide();
                                }
                            }
                            catch
                            {
                            }
                        }
                        catch (Exception exc)
                        {
                            string test = exc.Message;
                        }
                        finally
                        {
                            AMTANGEE.SDK.Documents.Documents.EndUpdate();
                        }
                    }
                }
                catch (Exception exc)
                {
                }

                if (parameter.ToLower().StartsWith("amtangee://"))
                {
                    parameter = parameter.Substring(11);
                }

                AMTANGEE.SDK.Settings.Helper settingsObject = AMTANGEE.SDK.Settings.PerUser["AMTANGEEURL"];

                string module = AMTANGEE.SDK.Global.CopyToPattern(parameter, '/');
                parameter = AMTANGEE.SDK.Global.CopyFromPattern(parameter, '/');
                System.Collections.Specialized.NameValueCollection nvc = System.Web.HttpUtility.ParseQueryString(parameter);
                if (module == "general")
                {
                    if (GetOption(parameter, "action") == "close")
                    {
                        System.Diagnostics.Process.GetCurrentProcess().Kill();
                        return;
                    }
                }

                nvc.Add("[USERGUID]", _userID);
                string referenzGUID = "";
                string referenzID   = "";
                if (GetOption(parameter, "reference").Trim().Length > 0)
                {
                    referenzID   = GetOption(parameter, "reference").ToUpper().Trim();
                    referenzGUID = settingsObject[GetOption(parameter, "reference").ToUpper().Trim()];
                }

                nvc.Add("[REF]", referenzID);
                nvc.Add("[REFGUID]", referenzGUID);

                if (module.ToLower() == "version")
                {
                    MessageBox.Show("AMTANGEE® Remote Url Version 3.0");
                    return;
                }

                if (module.ToLower() == "licenseholder")
                {
                    MessageBox.Show("Lizensiert für: " + AMTANGEE.SDK.License.LicensedTo);
                    return;
                }

                AMTANGEE.Remote.RemoteUrl.Exec(module, nvc);
            }
        }