Пример #1
0
 //
 //====================================================================================================
 //
 public static void addUserError(CoreController core, string Message)
 {
     if (!core.doc.userErrorList.Contains(Message))
     {
         core.doc.userErrorList.Add(Message);
     }
 }
        //
        //====================================================================================================
        /// <summary>
        /// Build collection folders for all collection files in a tempFiles folder
        /// - enumerate zip files in a folder and call buildCollectionFolderFromCollectionZip
        /// </summary>
        /// <param name="core"></param>
        /// <param name="sourceTempFolderPath"></param>
        /// <param name="CollectionLastChangeDate"></param>
        /// <param name="collectionsToInstall">A list of collection guids that need to be installed in the database. Any collection folders built are added to he collectionsToInstall list.</param>
        /// <param name="return_ErrorMessage"></param>
        /// <param name="collectionsInstalledList"></param>
        /// <param name="collectionsBuildingFolder">list of collection guids in the process of folder building. use to block recursive loop.</param>
        /// <returns></returns>
        public static bool buildCollectionFoldersFromCollectionZips(CoreController core, Stack <string> contextLog, string sourceTempFolderPath, DateTime CollectionLastChangeDate, ref List <string> collectionsToInstall, ref string return_ErrorMessage, ref List <string> collectionsInstalledList, ref List <string> collectionsBuildingFolder)
        {
            bool success = false;

            try {
                //
                contextLog.Push(MethodInfo.GetCurrentMethod().Name + ", [" + sourceTempFolderPath + "]");
                traceContextLog(core, contextLog);
                //
                if (core.tempFiles.pathExists(sourceTempFolderPath))
                {
                    LogController.logInfo(core, MethodInfo.GetCurrentMethod().Name + ", BuildLocalCollectionFolder, processing files in private folder [" + sourceTempFolderPath + "]");
                    List <CPFileSystemClass.FileDetail> SrcFileNamelist = core.tempFiles.getFileList(sourceTempFolderPath);
                    foreach (CPFileSystemClass.FileDetail file in SrcFileNamelist)
                    {
                        if ((file.Extension == ".zip") || (file.Extension == ".xml"))
                        {
                            success = buildCollectionFolderFromCollectionZip(core, contextLog, sourceTempFolderPath + file.Name, CollectionLastChangeDate, ref return_ErrorMessage, ref collectionsToInstall, ref collectionsInstalledList, ref collectionsBuildingFolder);
                        }
                    }
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            } finally {
                contextLog.Pop();
            }
            return(success);
        }
Пример #3
0
 //
 //=================================================================================
 /// <summary>
 /// Get a record lock status. If session.user is the lock holder, returns unlocked
 /// </summary>
 /// <param name="ContentName"></param>
 /// <param name="recordId"></param>
 /// <param name="ReturnMemberID"></param>
 /// <param name="ReturnDateExpires"></param>
 /// <returns></returns>
 public static editLockClass getEditLock(CoreController core, int tableId, int recordId)
 {
     try {
         var table = DbBaseModel.create <TableModel>(core.cpParent, tableId);
         if (table != null)
         {
             //
             // -- get the edit control for this record (not by this person) with the oldest expiration date
             string criteria             = "(createdby<>" + core.session.user.id + ")and" + getAuthoringControlCriteria(getTableRecordKey(table.id, recordId), AuthoringControls.Editing, core.dateTimeNowMockable);
             var    authoringControlList = DbBaseModel.createList <AuthoringControlModel>(core.cpParent, criteria, "dateexpires desc");
             if (authoringControlList.Count > 0)
             {
                 var person = DbBaseModel.create <PersonModel>(core.cpParent, GenericController.encodeInteger(authoringControlList.First().createdBy));
                 return(new editLockClass {
                     isEditLocked = true,
                     editLockExpiresDate = authoringControlList.First().dateExpires,
                     editLockByMemberId = (person == null) ? 0 : person.id,
                     editLockByMemberName = (person == null) ? "" : person.name
                 });
             }
         }
         ;
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
     return(new editLockClass {
         isEditLocked = false
     });
 }
Пример #4
0
        //
        //====================================================================================================
        /// <summary>
        /// Add a user to a group. If gorupId doesnt exist, an error is logged.
        /// </summary>
        /// <param name="core"></param>
        /// <param name="groupId"></param>
        /// <param name="userId"></param>
        /// <param name="dateExpires"></param>
        public static void addUser(CoreController core, int groupId, int userId, DateTime dateExpires)
        {
            var group = DbBaseModel.create <GroupModel>(core.cpParent, groupId);

            if (group == null)
            {
                //
                // -- inactive or invalid groupId
                //LogController.logError(core, new GenericException("addUser called with invalid groupId [" + groupId + "]"));
                return;
            }
            if (userId.Equals(0))
            {
                //
                // -- default to keyboard user
                userId = core.session.user.id;
            }
            PersonModel user = DbBaseModel.create <PersonModel>(core.cpParent, userId);

            if (user == null)
            {
                //
                // -- inactive or invalid userId
                //LogController.logError(core, new GenericException("addUser called with invalid userId [" + userId + "]"));
                return;
            }
            addUser(core, group, user, dateExpires);
        }
Пример #5
0
 //
 //=====================================================================================================
 /// <summary>
 /// add activity about a user to the site's activity log for content managers to review
 /// </summary>
 /// <param name="core"></param>
 /// <param name="Message"></param>
 /// <param name="ByMemberID"></param>
 /// <param name="SubjectMemberID"></param>
 /// <param name="SubjectOrganizationID"></param>
 /// <param name="Link"></param>
 /// <param name="VisitorID"></param>
 /// <param name="VisitID"></param>
 public static void addSiteActivity(CoreController core, string Message, int ByMemberID, int SubjectMemberID, int SubjectOrganizationID, string Link = "", int VisitorId = 0, int VisitId = 0)
 {
     try {
         //
         if (Message.Length > 255)
         {
             Message = Message.Substring(0, 255);
         }
         if (Link.Length > 255)
         {
             Message = Link.Substring(0, 255);
         }
         using (var csData = new CsModel(core)) {
             if (csData.insert("Activity Log"))
             {
                 csData.set("MemberID", SubjectMemberID);
                 csData.set("OrganizationID", SubjectOrganizationID);
                 csData.set("Message", Message);
                 csData.set("Link", Link);
                 csData.set("VisitorID", VisitorId);
                 csData.set("VisitID", VisitId);
             }
         }
         //
         return;
         //
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
 }
        //
        //====================================================================================================
        /// <summary>
        /// setOuter
        /// </summary>
        /// <param name="ignore"></param>
        /// <param name="layout"></param>
        /// <param name="Key"></param>
        /// <param name="textToInsert"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static string setOuter(CoreController core, string layout, string Key, string textToInsert)
        {
            string returnValue = "";

            try {
                if (string.IsNullOrEmpty(Key))
                {
                    returnValue = textToInsert;
                }
                else
                {
                    returnValue = layout;
                    int posStart = getTagStartPos(core, layout, 1, Key);
                    if (posStart != 0)
                    {
                        int posEnd = getTagEndPos(core, layout, posStart);
                        if (posEnd > 0)
                        {
                            //
                            // seems like these are the correct positions here.
                            //
                            returnValue = layout.left(posStart - 1) + textToInsert + layout.Substring(posEnd - 1);
                        }
                    }
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnValue);
        }
Пример #7
0
        //
        //====================================================================================================
        /// <summary>
        /// return a DES encrypted string. This is a two way so use it for little sister security, not foreign government security
        /// </summary>
        /// <param name="sourceToEncrypt"></param>
        /// <returns></returns>
        private static string encryptDes(CoreController core, string sourceToEncrypt)
        {
            string returnResult = "";

            try {
                if (string.IsNullOrEmpty(core.appConfig.privateKey))
                {
                    //
                }
                else
                {
                    // Compute has key using DES
                    byte[] saltBytes = ASCIIEncoding.ASCII.GetBytes("notsorandomsalt");
                    byte[] key       = ASCIIEncoding.ASCII.GetBytes(HashEncode.computeHash(core.appConfig.privateKey, "SHA512", saltBytes));
                    Array.Resize(ref key, 24);
                    TripleDESCryptoServiceProvider DES = new TripleDESCryptoServiceProvider {
                        Key  = key,
                        Mode = CipherMode.ECB
                    };
                    ICryptoTransform DESEncrypt = DES.CreateEncryptor();
                    byte[]           Buffer     = ASCIIEncoding.ASCII.GetBytes(sourceToEncrypt);
                    Buffer       = DESEncrypt.TransformFinalBlock(Buffer, 0, Buffer.Length);
                    returnResult = Convert.ToBase64String(Buffer);
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnResult);
        }
Пример #8
0
 //
 //=============================================================================
 /// <summary>
 /// Log all levels if configured, else log errors and above
 /// </summary>
 /// <param name="core"></param>
 /// <param name="message"></param>
 /// <param name="level"></param>
 public static void log(CoreController core, string message, BaseClasses.CPLogBaseClass.LogLevel level)
 {
     try {
         string messageLine    = getMessageLine(core, message);
         Logger loggerInstance = core.nlogLogger;
         loggerInstance.Log(typeof(LogController), new LogEventInfo(getNLogLogLevel(level), loggerInstance.Name, messageLine));
         //
         // -- add to doc exception list to display at top of webpage
         if (level < BaseClasses.CPLogBaseClass.LogLevel.Warn)
         {
             return;
         }
         if (core.doc.errorList == null)
         {
             core.doc.errorList = new List <string>();
         }
         if (core.doc.errorList.Count < 10)
         {
             core.doc.errorList.Add(messageLine);
             return;
         }
         if (core.doc.errorList.Count == 10)
         {
             core.doc.errorList.Add("Exception limit exceeded");
         }
     } catch (Exception) {
         // -- throw away errors in error-handling
     }
 }
Пример #9
0
        //
        //=============================================================================
        /// <summary>
        /// configure target "aws" for AWS CloudWatch
        /// </summary>
        /// <param name="core"></param>
        public static void awsConfigure(CoreController core)
        {
            if (core.serverConfig == null)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(core.serverConfig.awsCloudWatchLogGroup))
            {
                return;
            }
            var awsTarget = new AWSTarget {
                Layout              = "${longdate}|${level:uppercase=true}|${callsite}|${message}",
                LogGroup            = core.serverConfig.awsCloudWatchLogGroup,
                Region              = core.awsCredentials.awsRegion.DisplayName,
                Credentials         = new Amazon.Runtime.BasicAWSCredentials(core.awsCredentials.awsAccessKeyId, core.awsCredentials.awsSecretAccessKey),
                LogStreamNamePrefix = core.appConfig.name,
                LogStreamNameSuffix = "NLog",
                MaxQueuedMessages   = 5000
            };
            var config = new LoggingConfiguration();

            config.AddTarget("aws", awsTarget);
            config.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, awsTarget));
            LogManager.Configuration = config;
        }
Пример #10
0
 //
 //====================================================================================================
 /// <summary>
 /// Add a user to a group with an expiration date
 /// </summary>
 /// <param name="core"></param>
 /// <param name="group"></param>
 /// <param name="user"></param>
 /// <param name="dateExpires"></param>
 public static void addUser(CoreController core, GroupModel group, PersonModel user, DateTime dateExpires)
 {
     try {
         var ruleList = DbBaseModel.createList <MemberRuleModel>(core.cpParent, "(MemberID=" + user.id.ToString() + ")and(GroupID=" + group.id.ToString() + ")");
         if (ruleList.Count == 0)
         {
             // -- add new rule
             var rule = DbBaseModel.addDefault <MemberRuleModel>(core.cpParent, Models.Domain.ContentMetadataModel.getDefaultValueDict(core, "groups"));
             rule.groupId     = group.id;
             rule.memberId    = user.id;
             rule.dateExpires = dateExpires;
             rule.save(core.cpParent);
             return;
         }
         // at least one rule found, set expire date, delete the rest
         var ruleFirst = ruleList.First();
         if (ruleFirst.dateExpires != dateExpires)
         {
             ruleFirst.dateExpires = dateExpires;
             ruleFirst.save(core.cpParent);
         }
         if (ruleList.Count > 1)
         {
             foreach (var rule in ruleList)
             {
                 if (!rule.Equals(ruleFirst))
                 {
                     DbBaseModel.delete <MemberRuleModel>(core.cpParent, rule.id);
                 }
             }
         }
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
 }
Пример #11
0
 //
 //====================================================================================================
 /// <summary>
 /// Remove a user from a group.
 /// </summary>
 /// <param name="core"></param>
 /// <param name="group"></param>
 /// <param name="user"></param>
 public static void removeUser(CoreController core, GroupModel group, PersonModel user)
 {
     if ((group != null) && (user != null))
     {
         MemberRuleModel.deleteRows <MemberRuleModel>(core.cpParent, "(MemberID=" + DbController.encodeSQLNumber(user.id) + ")AND(groupid=" + DbController.encodeSQLNumber(group.id) + ")");
     }
 }
Пример #12
0
 //
 //========================================================================
 /// <summary>
 /// Create a filename for the Virtual Directory
 /// </summary>
 /// <param name="contentName"></param>
 /// <param name="fieldName"></param>
 /// <param name="recordId"></param>
 /// <param name="originalFilename"></param>
 /// <returns></returns>
 public static string getVirtualFilename(CoreController core, string contentName, string fieldName, int recordId, string originalFilename = "")
 {
     try {
         if (string.IsNullOrEmpty(contentName.Trim()))
         {
             throw new ArgumentException("contentname cannot be blank");
         }
         if (string.IsNullOrEmpty(fieldName.Trim()))
         {
             throw new ArgumentException("fieldname cannot be blank");
         }
         if (recordId <= 0)
         {
             throw new ArgumentException("recordid is not valid");
         }
         var meta = ContentMetadataModel.createByUniqueName(core, contentName);
         if (meta == null)
         {
             throw new ArgumentException("contentName is not valid");
         }
         string workingFieldName = fieldName.Trim().ToLowerInvariant();
         if (!meta.fields.ContainsKey(workingFieldName))
         {
             throw new ArgumentException("content metadata does not include field [" + fieldName + "]");
         }
         if (string.IsNullOrEmpty(originalFilename))
         {
             return(FileController.getVirtualRecordUnixPathFilename(meta.tableName, fieldName, recordId, meta.fields[fieldName.ToLowerInvariant()].fieldTypeId));
         }
         return(FileController.getVirtualRecordUnixPathFilename(meta.tableName, fieldName, recordId, originalFilename));
     } catch (Exception ex) {
         LogController.logError(core, ex);
         throw;
     }
 }
Пример #13
0
 //
 //====================================================================================================
 //
 public static void processAfterSave_AddonCollection(CoreController core, bool isDelete, string contentName, int recordID, string recordName, int recordParentID, bool useContentWatchLink)
 {
     //
     // -- if this is an add or delete, manage the collection folders
     if (isDelete)
     {
         //
         // todo - if a collection is deleted, consider deleting the collection folder (or saving as archive)
     }
     else
     {
         //
         // -- add or modify collection, verify collection /addon folder
         var addonCollection = AddonCollectionModel.create <AddonCollectionModel>(core.cpParent, recordID);
         if (addonCollection != null)
         {
             string CollectionVersionFolderName = CollectionFolderController.verifyCollectionVersionFolderName(core, addonCollection.ccguid, addonCollection.name);
             if (string.IsNullOrEmpty(CollectionVersionFolderName))
             {
                 //
                 // -- new collection
                 string CollectionVersionFolder = AddonController.getPrivateFilesAddonPath() + CollectionVersionFolderName;
                 core.privateFiles.createPath(CollectionVersionFolder);
                 CollectionFolderController.updateCollectionFolderConfig(core, addonCollection.name, addonCollection.ccguid, core.dateTimeNowMockable, CollectionVersionFolderName);
             }
         }
     }
 }
        //
        //====================================================================================================
        /// <summary>
        /// getOuterHTML
        /// </summary>
        /// <param name="ignore"></param>
        /// <param name="layout"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static string getOuter(CoreController core, string layout, string key)
        {
            string result = "";

            try {
                if ((string.IsNullOrEmpty(key)) || (string.IsNullOrEmpty(layout)))
                {
                    return(string.Empty);
                }
                string workingLayout = layout;
                int    posStart      = getTagStartPos(core, workingLayout, 1, key);
                if (posStart > 0)
                {
                    //
                    // now backtrack to include the leading whitespace
                    while ((posStart > 0) && (("\t\r\n\t ").IndexOf(workingLayout.Substring(posStart - 1, 1)) != -1))
                    {
                        posStart = posStart - 1;
                    }
                    workingLayout = workingLayout.Substring(posStart - 1);
                    int posEnd = getTagEndPos(core, workingLayout, 1);
                    if (posEnd > 0)
                    {
                        workingLayout = workingLayout.left(posEnd - 1);
                        result        = workingLayout;
                    }
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(result);
        }
Пример #15
0
        //
        //
        //
        //
        public static string main_GetRemoteQueryKey(CoreController core, string SQL, string dataSourceName = "default", int maxRows = 1000)
        {
            string remoteKey = "";

            if (maxRows == 0)
            {
                maxRows = 1000;
            }
            using (var cs = new CsModel(core)) {
                cs.insert("Remote Queries");
                if (cs.ok())
                {
                    remoteKey = getGUIDNaked();
                    cs.set("remotekey", remoteKey);
                    cs.set("datasourceid", MetadataController.getRecordIdByUniqueName(core, "Data Sources", dataSourceName));
                    cs.set("sqlquery", SQL);
                    cs.set("maxRows", maxRows);
                    cs.set("dateexpires", DbController.encodeSQLDate(core.doc.profileStartTime.AddDays(1)));
                    cs.set("QueryTypeID", QueryTypeSQL);
                    cs.set("VisitId", core.session.visit.id);
                }
                cs.close();
            }
            //
            return(remoteKey);
        }
Пример #16
0
        //
        //====================================================================================================
        //
        public static string getActiveEditor(CoreController core, string ContentName, int RecordID, string FieldName, string FormElements = "")
        {
            //
            int    ContentID      = 0;
            string Copy           = null;
            string Stream         = "";
            string ButtonPanel    = null;
            string EditorPanel    = null;
            string PanelCopy      = null;
            string intContentName = null;
            int    intRecordId    = 0;
            string strFieldName   = null;

            //
            intContentName = GenericController.encodeText(ContentName);
            intRecordId    = GenericController.encodeInteger(RecordID);
            strFieldName   = GenericController.encodeText(FieldName);
            //
            EditorPanel = "";
            ContentID   = Models.Domain.ContentMetadataModel.getContentId(core, intContentName);
            if ((ContentID < 1) || (intRecordId < 1) || (string.IsNullOrEmpty(strFieldName)))
            {
                PanelCopy   = SpanClassAdminNormal + "The information you have selected can not be accessed.</span>";
                EditorPanel = EditorPanel + core.html.getPanel(PanelCopy);
            }
            else
            {
                intContentName = MetadataController.getContentNameByID(core, ContentID);
                if (!string.IsNullOrEmpty(intContentName))
                {
                    using (var csData = new CsModel(core)) {
                        csData.open(intContentName, "ID=" + intRecordId);
                        if (!csData.ok())
                        {
                            PanelCopy   = SpanClassAdminNormal + "The information you have selected can not be accessed.</span>";
                            EditorPanel = EditorPanel + core.html.getPanel(PanelCopy);
                        }
                        else
                        {
                            Copy        = csData.getText(strFieldName);
                            EditorPanel = EditorPanel + HtmlController.inputHidden("Type", FormTypeActiveEditor);
                            EditorPanel = EditorPanel + HtmlController.inputHidden("cid", ContentID);
                            EditorPanel = EditorPanel + HtmlController.inputHidden("ID", intRecordId);
                            EditorPanel = EditorPanel + HtmlController.inputHidden("fn", strFieldName);
                            EditorPanel = EditorPanel + GenericController.encodeText(FormElements);
                            EditorPanel = EditorPanel + core.html.getFormInputHTML("ContentCopy", Copy, "3", "45", false, true);
                            ButtonPanel = core.html.getPanelButtons(ButtonCancel + "," + ButtonSave);
                            EditorPanel = EditorPanel + ButtonPanel;
                        }
                        csData.close();
                    }
                }
            }
            Stream = Stream + core.html.getPanelHeader("Contensive Active Content Editor");
            Stream = Stream + core.html.getPanel(EditorPanel);
            Stream = HtmlController.form(core, Stream);
            return(Stream);
        }
Пример #17
0
 //
 //========================================================================
 /// <summary>
 /// create an encrypted token with an integer and a date
 /// </summary>
 /// <param name="core"></param>
 /// <param name="keyInteger"></param>
 /// <param name="expiresDate"></param>
 /// <returns></returns>
 public static string encodeToken(CoreController core, int keyInteger, DateTime expiresDate)
 {
     try {
         return(twoWayEncrypt(core, keyInteger.ToString() + "\t" + expiresDate.ToString("yyyy-MM-dd'T'HH:mm:ss")));
     } catch (Exception ex) {
         LogController.logError(core, ex, "EncodeToken failure. Returning blank result for keyInteger [" + keyInteger + "], keyDate [" + expiresDate + "]");
         return("");
     }
 }
Пример #18
0
 //
 //====================================================================================================
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="core"></param>
 public DocController(CoreController core)
 {
     this.core = core;
     //
     errorList        = new List <string>();
     pageController   = new PageContentController();
     domain           = new DomainModel();
     wysiwygAddonList = new Dictionary <CPHtml5BaseClass.EditorContentType, string>();
 }
Пример #19
0
 //
 //==========================================================================================
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="cp"></param>
 /// <remarks></remarks>
 public DbServerController(CoreController core)
 {
     try {
         this.core = core;
     } catch (Exception ex) {
         LogController.logError(core, ex);
         throw;
     }
 }
Пример #20
0
 //
 //========================================================================
 // ----- Process the send password form
 //
 public static void processSendPasswordForm(CoreController core)
 {
     try {
         string returnUserMessage = "";
         sendPassword(core, core.docProperties.getText("email"), ref returnUserMessage);
     } catch (Exception ex) {
         LogController.logError(core, ex);
         throw;
     }
 }
Пример #21
0
        //
        //====================================================================================================
        /// <summary>
        /// Get a group Id
        /// </summary>
        /// <param name="core"></param>
        /// <param name="GroupName"></param>
        /// <returns></returns>
        public static int getGroupId(CoreController core, string GroupName)
        {
            var group = DbBaseModel.createByUniqueName <GroupModel>(core.cpParent, GroupName);

            if (group != null)
            {
                return(group.id);
            }
            return(0);
        }
Пример #22
0
        //
        //====================================================================================================
        /// <summary>
        /// Get a group Name
        /// </summary>
        /// <param name="core"></param>
        /// <param name="groupId"></param>
        /// <returns></returns>
        public static string getGroupName(CoreController core, int groupId)
        {
            var group = DbBaseModel.create <GroupModel>(core.cpParent, groupId);

            if (group != null)
            {
                return(group.name);
            }
            return(String.Empty);
        }
Пример #23
0
        //
        // todo rename metadata as meta
        //========================================================================
        /// <summary>
        /// returns true if the metadata field exists
        /// </summary>
        /// <param name="ContentID"></param>
        /// <param name="FieldName"></param>
        /// <returns></returns>
        public static bool isMetadataField(CoreController core, int ContentID, string FieldName)
        {
            var meta = ContentMetadataModel.create(core, ContentID);

            if (meta == null)
            {
                return(false);
            }
            return(meta.fields.ContainsKey(FieldName.Trim().ToLower(CultureInfo.InvariantCulture)));
        }
Пример #24
0
 //
 //====================================================================================================
 /// <summary>
 /// Create a topic. The actual topic will be appended to the appName
 /// </summary>
 /// <param name="core"></param>
 /// <param name="topic"></param>
 /// <returns></returns>
 public static string createTopic(CoreController core, AmazonSimpleNotificationServiceClient snsClient, string topic)
 {
     try {
         var topicResponse = snsClient.CreateTopic(core.appConfig.name + "_" + topic);
         return(topicResponse.TopicArn);
     } catch (Exception ex) {
         LogController.logError(core, ex);
         return("");
     }
 }
Пример #25
0
        //
        //====================================================================================================
        /// <summary>
        /// Get a list of topics for this app.
        /// </summary>
        /// <param name="core"></param>
        /// <returns></returns>
        public static List <string> getTopicList(CoreController core, AmazonSimpleNotificationServiceClient snsClient)
        {
            var result             = new List <string>();
            var listTopicsResponse = snsClient.ListTopics();

            foreach (var topic in listTopicsResponse.Topics)
            {
                result.Add(topic.ToString());
            }
            return(result);
        }
Пример #26
0
        //
        //======================================================================================
        public static string getWebAddressProtocolDomain(CoreController core)
        {
            //
            // -- This value is determined during installation and saved in the ecdnFileUrl appConfig property
            //
            // -- local file system
            string webAddressProtocolDomain = core.siteProperties.getText("webAddressProtocolDomain");

            //
            // -- if site property is empty, use https + first domain in domain list
            return(string.IsNullOrWhiteSpace(webAddressProtocolDomain) ? "https://" + core.appConfig.domainList[0] : webAddressProtocolDomain);
        }
Пример #27
0
 //
 //====================================================================================================
 /// <summary>
 /// Return the URL protocol + domain + "/" to be used to prepend rroot relative urls in images, links, etc
 /// </summary>
 /// <param name="core"></param>
 /// <returns></returns>
 public static string getCdnFilePathPrefixAbsolute(CoreController core)
 {
     //
     // -- if remote file system, return the cdnFileUrl
     if (!core.serverConfig.isLocalFileSystem)
     {
         return(core.appConfig.cdnFileUrl);
     }
     //
     // -- local file system
     return(getWebAddressProtocolDomain(core) + core.appConfig.cdnFileUrl);
 }
Пример #28
0
        //
        //========================================================================
        /// <summary>
        /// 'deleteContentRecords
        /// </summary>
        /// <param name="contentName"></param>
        /// <param name="sqlCriteria"></param>
        /// <param name="userId"></param>
        //
        public static void deleteContentRecords(CoreController core, string contentName, string sqlCriteria, int userId = 0)
        {
            var meta = ContentMetadataModel.createByUniqueName(core, contentName);

            if (meta == null)
            {
                return;
            }
            using (var db = new DbController(core, meta.dataSourceName)) {
                core.db.deleteRows(meta.tableName, sqlCriteria);
            }
        }
Пример #29
0
        //
        //========================================================================
        /// <summary>
        /// Delete Content Record
        /// </summary>
        /// <param name="contentName"></param>
        /// <param name="recordId"></param>
        /// <param name="userId"></param>
        //
        public static void deleteContentRecord(CoreController core, string contentName, int recordId, int userId = SystemMemberId)
        {
            var meta = ContentMetadataModel.createByUniqueName(core, contentName);

            if (meta == null)
            {
                return;
            }
            using (var db = new DbController(core, meta.dataSourceName)) {
                core.db.delete(recordId, meta.tableName);
            }
        }
Пример #30
0
        //
        //====================================================================================================
        /// <summary>
        /// return an encrypted string. This is a one way so use it passwords, etc.
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public static string oneWayEncrypt(CoreController core, string password)
        {
            string returnResult = "";

            try {
                returnResult = HashEncode.computeHash(password, "SHA512", null);
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnResult);
        }