Beispiel #1
0
        /// <summary>
        /// Загрузить адресную книгу или получить её из общих свойств линии связи
        /// </summary>
        private void LoadAddressBook()
        {
            object addrBookObj;

            if (CommonProps.TryGetValue("AddressBook", out addrBookObj))
            {
                addressBook = addrBookObj as AB.AddressBook;
            }
            else
            {
                addressBook = new AB.AddressBook();
                CommonProps.Add("AddressBook", addressBook);

                string fileName = AppDirs.ConfigDir + AB.AddressBook.DefFileName;
                if (File.Exists(fileName))
                {
                    WriteToLog(Localization.UseRussian ?
                               "Загрузка адресной книги" :
                               "Loading address book");
                    string errMsg;
                    if (!addressBook.Load(fileName, out errMsg))
                    {
                        WriteToLog(errMsg);
                    }
                }
                else
                {
                    WriteToLog(Localization.UseRussian ?
                               "Адресная книга отсутствует" :
                               "Address book is missing");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets or creates the template dictionary from the common line properties.
        /// </summary>
        private TemplateDict GetTemplateDictionary()
        {
            TemplateDict templateDict = CommonProps.ContainsKey(TemplateDictKey) ?
                                        CommonProps[TemplateDictKey] as TemplateDict : null;

            if (templateDict == null)
            {
                templateDict = new TemplateDict();
                CommonProps.Add(TemplateDictKey, templateDict);
            }

            return(templateDict);
        }
Beispiel #3
0
        /// <summary>
        /// Получить из общих свойств линии связи или создать список сообщений, представленных в виде object[]
        /// </summary>
        private List <object[]> GetMessageObjList()
        {
            List <object[]> messages = CommonProps.ContainsKey("Messages") ?
                                       CommonProps["Messages"] as List <object[]> : null;

            if (messages == null)
            {
                messages = new MessageObjList();
                CommonProps.Add("Messages", messages);
            }

            return(messages);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the template dictionary from the common properties or creates it.
        /// </summary>
        private Dictionary <string, DeviceTemplate> GetTemplateDictionary()
        {
            Dictionary <string, DeviceTemplate> templateDict = CommonProps.ContainsKey(TemplateDictKey) ?
                                                               CommonProps[TemplateDictKey] as Dictionary <string, DeviceTemplate> : null;

            if (templateDict == null)
            {
                templateDict = new TemplateDict();
                CommonProps.Add(TemplateDictKey, templateDict);
            }

            return(templateDict);
        }
Beispiel #5
0
        /// <summary>
        /// Получить из общих свойств линии связи или создать словарь шаблонов устройств
        /// </summary>
        private Dictionary <string, DeviceTemplate> GetTemplates()
        {
            Dictionary <string, DeviceTemplate> templates = CommonProps.ContainsKey("Templates") ?
                                                            CommonProps["Templates"] as Dictionary <string, DeviceTemplate> : null;

            if (templates == null)
            {
                templates = new TemplateDict();
                CommonProps.Add("Templates", templates);
            }

            return(templates);
        }
Beispiel #6
0
        /// <summary>
        /// Выполнить действия при запуске линии связи
        /// </summary>
        public override void OnCommLineStart()
        {
            // определение, является ли КП основным на линии связи
            // основным автоматически считается первый КП на линии связи
            object primaryObj;

            if (CommonProps.TryGetValue("KpSmsPrimary", out primaryObj))
            {
                primary     = false;
                addressBook = null;
            }
            else
            {
                primary = true;
                CommonProps.Add("KpSmsPrimary", Caption);

                // загрузка адресной книги
                string fileName = AppDirs.ConfigDir + AB.AddressBook.DefFileName;
                if (File.Exists(fileName))
                {
                    WriteToLog(Localization.UseRussian ?
                               "Загрузка адресной книги" :
                               "Loading address book");
                    addressBook = new AB.AddressBook();
                    string errMsg;
                    if (!addressBook.Load(fileName, out errMsg))
                    {
                        WriteToLog(errMsg);
                    }
                }
                else
                {
                    addressBook = null;
                    WriteToLog(Localization.UseRussian ?
                               "Адресная книга отсутствует" :
                               "Address book is missing");
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Выполнить действия при запуске линии связи
        /// </summary>
        public override void OnCommLineStart()
        {
            // определение, является ли КП основным на линии связи
            // основным автоматически считается первый КП на линии связи
            object primaryObj;

            if (CommonProps.TryGetValue("KpSmsPrimary", out primaryObj))
            {
                primary   = false;
                phonebook = null;
            }
            else
            {
                primary = true;
                CommonProps.Add("KpSmsPrimary", Caption);

                // загрузка телефонного справочника
                string fileName = AppDirs.ConfigDir + Phonebook.DefFileName;
                if (File.Exists(fileName))
                {
                    WriteToLog(Localization.UseRussian ?
                               "Загрузка телефонного справочника" :
                               "Loading phone book");
                    phonebook = new Phonebook();
                    string errMsg;
                    if (!phonebook.Load(fileName, out errMsg))
                    {
                        ScadaUtils.ShowError(errMsg);
                    }
                }
                else
                {
                    phonebook = null;
                    WriteToLog(Localization.UseRussian ?
                               "Телефонный справочник отсутствует" :
                               "Phone book is missing");
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Выполнить действия при запуске линии связи
        /// </summary>
        public override void OnCommLineStart()
        {
            // определение, является ли КП основным на линии связи
            // основным автоматически считается первый КП на линии связи
            object primaryObj;

            if (CommonProps.TryGetValue("KpSmsPrimary", out primaryObj))
            {
                primary     = false;
                addressBook = null;
            }
            else
            {
                primary = true;
                CommonProps.Add("KpSmsPrimary", Caption);

                // загрузка адресной книги
                if (!AbUtils.LoadAddressBook(AppDirs.ConfigDir, WriteToLog, out addressBook))
                {
                    addressBook = null;
                }
            }
        }
Beispiel #9
0
        private static void RegisterMailTypes(OutlookPlugin ownerPlugin, IContactManager contactManager)
        {
            if (RS.ResourceTypes.Exist("MAPIFolderRoot"))
            {
                IResourceList resourcesToDelete = RS.GetAllResources("MAPIFolderRoot");
                foreach (IResource resource in resourcesToDelete)
                {
                    resource.Delete();
                }
            }
            RegisterResources(ownerPlugin);
            PROP.SyncVersion =
                RS.PropTypes.Register(STR.SyncVersion, PropDataType.Int, PropTypeFlags.Internal | PropTypeFlags.NoSerialize);

            PROP.EntryID = ResourceTypeHelper.UpdatePropTypeRegistration(STR.EntryID, PropDataType.String,
                                                                         PropTypeFlags.Internal | PropTypeFlags.NoSerialize);
            PROP.StoreID   = RS.PropTypes.Register(STR.StoreID, PropDataType.String, PropTypeFlags.Internal | PropTypeFlags.NoSerialize);
            PROP.RecordKey = ResourceTypeHelper.UpdatePropTypeRegistration(STR.RecordKey, PropDataType.String,
                                                                           PropTypeFlags.Internal | PropTypeFlags.NoSerialize);
            PROP.InternetMsgID = ResourceTypeHelper.UpdatePropTypeRegistration(STR.InternetMsgID,
                                                                               PropDataType.String, PropTypeFlags.Internal);
            PROP.ReplyTo                  = ResourceTypeHelper.UpdatePropTypeRegistration(STR.ReplyTo, PropDataType.String, PropTypeFlags.Internal);
            PROP.ConversationIndex        = RS.PropTypes.Register("ConversationIndex", PropDataType.String, PropTypeFlags.Internal);
            PROP.ReplyToConversationIndex = RS.PropTypes.Register("ReplyToConversationIndex", PropDataType.String, PropTypeFlags.Internal);

            PROP.SentOn          = RS.PropTypes.Register(STR.SentOn, PropDataType.Date);
            PROP.LastReceiveDate = RS.PropTypes.Register(STR.LastReceiveDate, PropDataType.Date);

            PROP.Extension       = RS.PropTypes.Register(STR.Extension, PropDataType.String);
            PROP.ResType         = RS.PropTypes.Register("ResType", PropDataType.String, PropTypeFlags.Internal);
            PROP.AttachmentIndex = RS.PropTypes.Register(STR.AttachmentIndex, PropDataType.Int, PropTypeFlags.Internal);
            PROP.AttachMethod    = RS.PropTypes.Register(STR.AttachMethod, PropDataType.Int, PropTypeFlags.Internal);

            PROP.ResourceTransfer = RS.PropTypes.Register("ResorceTransfer", PropDataType.Bool, PropTypeFlags.Internal);

            CorrectDeletedItemsProperty();

            PROP.DeletedInIMAP         = RS.PropTypes.Register("DeletedInIMAP", PropDataType.Bool, PropTypeFlags.Internal);
            PROP.IgnoredFolder         = RS.PropTypes.Register("IgnoredFolder", PropDataType.Int, PropTypeFlags.Internal);
            PROP.DefaultFolderEntryIDs = RS.PropTypes.Register(STR.DefaultFolderEntryIDs, PropDataType.StringList, PropTypeFlags.Internal);
            PROP.MySelf           = Core.ContactManager.Props.Myself;
            PROP.Imported         = RS.PropTypes.Register(STR.Imported, PropDataType.Int, PropTypeFlags.Internal);
            PROP.OpenIgnoreFolder = RS.PropTypes.Register("OpenIgnoreFolder", PropDataType.Int, PropTypeFlags.Internal);
            PROP.OpenSelectFolder = RS.PropTypes.Register("OpenSelectFolder", PropDataType.Int, PropTypeFlags.Internal);
            PROP.MessageFlag      = RS.PropTypes.Register(STR.MessageFlag, PropDataType.String, PropTypeFlags.Internal);
            PROP.LastModifiedTime = ResourceTypeHelper.UpdatePropTypeRegistration("LastModifiedTime",
                                                                                  PropDataType.Date, PropTypeFlags.Internal);
            PROP.Priority        = RS.PropTypes.Register(STR.Priority, PropDataType.Int);
            PROP.EmbeddedMessage = RS.PropTypes.Register(STR.EmbeddedMessage, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.Importance      = RS.PropTypes.Register(STR.Importance, PropDataType.Int);
            PROP.SeeAll          = RS.PropTypes.Register("SeeAll", PropDataType.Bool, PropTypeFlags.Internal);
            PROP.ContainerClass  = RS.PropTypes.Register(STR.ContainerClass, PropDataType.String, PropTypeFlags.Internal);
            PROP.BodyFormat      = RS.PropTypes.Register(STR.BodyFormat, PropDataType.String, PropTypeFlags.Internal);
            PROP.DefaultFolder   = RS.PropTypes.Register(STR.DefaultFolder, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.MAPIVisible     = RS.PropTypes.Register(STR.MAPIVisible, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.ShowPictures    = RS.PropTypes.Register(STR.ShowPictures, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.NoFormat        = RS.PropTypes.Register(STR.NoFormat, PropDataType.Bool, PropTypeFlags.Internal);

            PROP.SyncComplete          = RS.PropTypes.Register("SyncComplete", PropDataType.Bool, PropTypeFlags.Internal);
            PROP.Target                = ResourceTypeHelper.UpdatePropTypeRegistration("Target", PropDataType.Link, PropTypeFlags.DirectedLink);
            PROP.IgnoreContactImport   = RS.PropTypes.Register(STR.IgnoreContactImport, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.DeletedItemsFolder    = RS.PropTypes.Register(STR.DeletedItemsFolder, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.DefaultDeletedItems   = RS.PropTypes.Register(STR.DefaultDeletedItems, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.DeletedItemsEntryID   = RS.PropTypes.Register(STR.DeletedItemsEntryID, PropDataType.String, PropTypeFlags.Internal);
            PROP.JunkEmailEntryID      = RS.PropTypes.Register(STR.JunkEmailEntryID, PropDataType.String, PropTypeFlags.Internal);
            PROP.PR_STORE_SUPPORT_MASK = RS.PropTypes.Register(STR.PR_STORE_SUPPORT_MASK, PropDataType.Int, PropTypeFlags.Internal);
            PROP.StoreSupported        = RS.PropTypes.Register(STR.StoreSupported, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.StoreTypeChecked      = RS.PropTypes.Register(STR.StoreTypeChecked, PropDataType.Bool, PropTypeFlags.Internal);
            PROP.PR_CONTENT_COUNT      = RS.PropTypes.Register(STR.PR_CONTENT_COUNT, PropDataType.Int, PropTypeFlags.Internal);
            PROP.PR_ICON_INDEX         = RS.PropTypes.Register(STR.PR_ICON_INDEX, PropDataType.Int, PropTypeFlags.Internal);
            CommonProps.Register();

            if (RS.PropTypes.Exist(STR.PR_ATTACH_CONTENT_ID))
            {
                IResourceList list = RS.FindResourcesWithProp(STR.Email, STR.PR_ATTACH_CONTENT_ID);
                foreach (IResource mail in list)
                {
                    mail.SetProp(CommonProps.ContentId, mail.GetStringProp(STR.PR_ATTACH_CONTENT_ID));
                    mail.DeleteProp(STR.PR_ATTACH_CONTENT_ID);
                }
                IPropType propType = RS.PropTypes[STR.PR_ATTACH_CONTENT_ID];
                RS.PropTypes.Delete(propType.Id);
            }
            PROP.PR_ATTACH_NUM = RS.PropTypes.Register(STR.PR_ATTACH_NUM, PropDataType.Int, PropTypeFlags.Internal);
            PROP.LastMailDate  = RS.PropTypes.Register(STR.LastMailDate, PropDataType.Date, PropTypeFlags.Internal);
            PROP.OMTaskId      = RS.PropTypes.Register(STR.OMTaskId, PropDataType.String, PropTypeFlags.Internal | PropTypeFlags.NoSerialize);

            PROP.AttachmentPicWidth  = RS.PropTypes.Register(STR.Width, PropDataType.Int, PropTypeFlags.Internal);
            PROP.AttachmentPicHeight = RS.PropTypes.Register(STR.Height, PropDataType.Int, PropTypeFlags.Internal);

            PROP.From = contactManager.Props.LinkFrom;
            PROP.To   = contactManager.Props.LinkTo;
            PROP.CC   = contactManager.Props.LinkCC;

            PROP.EmailAccountFrom = Core.ContactManager.Props.LinkEmailAcctFrom;
            PROP.EmailAccountTo   = Core.ContactManager.Props.LinkEmailAcctTo;
            PROP.EmailAccountCC   = Core.ContactManager.Props.LinkEmailAcctCC;
            RS.RegisterLinkRestriction(STR.Email, PROP.From, "Contact", 0, 1);

            PROP.SelectedInFolder = RS.PropTypes.Register("SelectedInFolder", PropDataType.Link, PropTypeFlags.Internal);

            PROP.Attachment = Core.ResourceStore.PropTypes.Register(STR.Attachment, PropDataType.Link,
                                                                    PropTypeFlags.SourceLink | PropTypeFlags.DirectedLink, ownerPlugin);
            RS.PropTypes.RegisterDisplayName(PROP.Attachment, "Outlook Message", "Attachment");

            PROP.AttType            = RS.PropTypes.Register(STR.AttachmentType, PropDataType.Link, PropTypeFlags.Internal);
            PROP.OwnerStore         = RS.PropTypes.Register("OwnerStore", PropDataType.Link, PropTypeFlags.Internal);
            PROP.TopLevelCategory   = RS.PropTypes.Register("TopLevelCategory", PropDataType.Link, PropTypeFlags.Internal);
            PROP.InternalAttachment = RS.PropTypes.Register("InternalAttachment", PropDataType.Link, PropTypeFlags.Internal);

            IResource     propMAPIFolderLink = RS.FindUniqueResource("PropType", "Name", STR.MAPIFolder);
            PropTypeFlags flags = PropTypeFlags.Normal | PropTypeFlags.CountUnread;

            if (propMAPIFolderLink != null)
            {
                propMAPIFolderLink.SetProp("Flags", (int)flags);
                PROP.MAPIFolder = propMAPIFolderLink.GetIntProp("ID");
            }
            else
            {
                PROP.MAPIFolder = RS.PropTypes.Register(STR.MAPIFolder, PropDataType.Link, flags);
            }
            RS.PropTypes.RegisterDisplayName(PROP.MAPIFolder, "Outlook Folder");

            RS.ResourceTypes.Register(STR.Task, "Subject");

            RS.RegisterUniqueRestriction(STR.Email, PROP.EntryID);
            RS.RegisterUniqueRestriction(STR.OutlookABDescriptor, PROP.EntryID);
            RS.RegisterUniqueRestriction("AddressBook", PROP.EntryID);
            RS.RegisterUniqueRestriction(STR.MAPIInfoStore, PROP.EntryID);
            RS.RegisterUniqueRestriction(STR.MAPIInfoStore, PROP.DeletedItemsEntryID);
            RS.RegisterUniqueRestriction(STR.MAPIInfoStore, PROP.JunkEmailEntryID);
            RS.RegisterUniqueRestriction("Contact", PROP.EntryID);
            RS.RegisterUniqueRestriction(STR.MAPIStore, PROP.StoreID);

            RS.RegisterLinkRestriction(STR.Email, PROP.MAPIFolder, STR.MAPIFolder, 0, 1);
            RS.RegisterUniqueRestriction(STR.MAPIFolder, PROP.EntryID);
            RS.RegisterLinkRestriction(STR.MAPIFolder, Core.Props.Parent, null, 1, 1);
            RS.RegisterLinkRestriction(STR.MAPIFolder, PROP.OwnerStore, STR.MAPIStore, 1, 1);
            RS.RegisterLinkRestriction(STR.Email, PROP.OwnerStore, STR.MAPIStore, 0, 1);
            RS.DeleteUniqueRestriction(STR.Task, PROP.OMTaskId);
            RS.RegisterUniqueRestriction(STR.Task, PROP.EntryID);

            RemoveInvalidAttachmentResources();
            RemoveAttachmentResources();
            UpdateOutlookAttachments( );
            ChangeDatePropForMAPIStore();

            PROP.Status      = RS.PropTypes.Register("Status", PropDataType.Int);
            PROP.RemindDate  = RS.PropTypes.Register("RemindDate", PropDataType.Date);
            PROP.StartDate   = RS.PropTypes.Register("StartDate", PropDataType.Date);
            PROP.Description = RS.PropTypes.Register("Description", PropDataType.String);
            //  NB: this prop format must coinside with that in TasksPlugin.
            PROP.SuperTaskLink = RS.PropTypes.Register(STR.SuperTaskLink, PropDataType.Link, PropTypeFlags.DirectedLink | PropTypeFlags.Internal);
            RS.ResourceTypes.Register("SentItemsEnumSign", "", ResourceTypeFlags.NoIndex | ResourceTypeFlags.Internal);
            UpdateLastMailDateForFolders();
            RemoveWrongGlobalBooks();
            RemoveOMTaskIDs();
            UpdateDeletedItemsFolders();
            DeleteInvalidMAPIFolders();
            UpdateMapiInfoStores();
            _registered = true;
        }