Example #1
0
        /// <summary>
        /// Builds the ClickOnce manifest for the client, using the configuration from env.xml and manifest templates from the Templates directory.
        /// </summary>
        /// <param name="envConfig"></param>
        internal static void BuildClickOnce(EnvConfig envConfig)
        {
            if (envConfig.ClickOnce == null) return;

            var origCurrDir = Environment.CurrentDirectory;
            try
            {
                Program.LogTitle("Creating ClickOnce manifest");
                Environment.CurrentDirectory = envConfig.BinaryTarget;
                Program.LogDetail("Changed CWD to BinaryTarget: [{0}]", Environment.CurrentDirectory);
                var appId = new AppId()
                {
                    name = envConfig.ClickOnce.Product + ".exe",
                    version = envConfig.ClickOnce.DeploymentVersion,
                    publicKeyToken = FormatKey(PublicKeyTokenFromPfx(envConfig.ClickOnce.KeyFile)),
                    language = "neutral",
                    processorArchitecture = "bar",
                    type = "win32",
                };

                CreateClickOnceManifest(envConfig, appId);
                Sign(envConfig, appId, GetManifestTemplateName(envConfig), GetManifestName(envConfig));
                CreateClickOnceAppplication(envConfig, appId);
                Sign(envConfig, appId, GetAppTemplateName(envConfig), GetAppName(envConfig));
            }
            finally
            {
                Environment.CurrentDirectory = origCurrDir;
                Program.LogDetail("Changed CWD back to [{0}]", Environment.CurrentDirectory);
            }
        }
Example #2
0
 private static void Sign(EnvConfig envConfig, AppId appId, string templateName, string outputName)
 {
     switch (Environment.OSVersion.Platform)
     {
         case PlatformID.Unix:
             SignXmlSec1(envConfig, templateName, outputName, appId);
             break;
         case PlatformID.Win32NT:
             SignMage(envConfig, templateName, outputName);
             break;
         default:
             throw new NotSupportedException(string.Format("Signing on platform '{0}' is not supported", Environment.OSVersion.Platform));
     }
 }
Example #3
0
        private static void CreateClickOnceManifest(EnvConfig envConfig, AppId appId)
        {
            var doc = LoadXmlFromResource("PrepareEnv.Templates.ClickOnce.manifest.xml");
            var nsmgr = CreateDefaultXmlNsmgr(doc);

            // fixup primary asmv1:assemblyIdentity
            var assemblyIdentity1 = doc.SelectSingleNode("/asmv1:assembly/asmv1:assemblyIdentity", nsmgr);

            var clientName = FillAppId(envConfig, assemblyIdentity1, appId);

            // fixup entryPoint's assemblyIdentity
            var entryPointId = doc.SelectSingleNode("/asmv1:assembly/asmv2:entryPoint/asmv2:assemblyIdentity", nsmgr);
            FillClickOnceAssemblyId(clientName, entryPointId);

            // fixup Icon
            var description = doc.SelectSingleNode("/asmv1:assembly/asmv1:description", nsmgr);
            description.Attributes["asmv2:iconFile"].Value = Path.GetFileName(envConfig.ClientExe);

            // set the startup paramters
            var entryPointCli = doc.SelectSingleNode("/asmv1:assembly/asmv2:entryPoint/asmv2:commandLine", nsmgr);
            entryPointCli.Attributes["file"].Value = Path.GetFileName(envConfig.ClientExe);
            entryPointCli.Attributes["parameters"].Value = envConfig.ClientParameters;

            // insert deployed files
            var dependencyList = doc.SelectSingleNode("/asmv1:assembly", nsmgr);
            var lastPrerequisite = doc.SelectNodes("/asmv1:assembly/asmv2:dependency", nsmgr).OfType<XmlNode>().Last();
            foreach (var baseName in new[] { "Common", "Client" })
            {
                foreach (var pattern in new[] { "*.dll", "*.exe", "*.exe.config" })
                {
                    foreach (var file in Directory.EnumerateFiles(baseName, pattern, SearchOption.AllDirectories))
                    {
                        InsertClickOnceDependency(envConfig, dependencyList, lastPrerequisite, file, nsmgr);
                    }
                }
            }

            // Add Client EXE and config
            InsertClickOnceDependency(envConfig, dependencyList, lastPrerequisite, envConfig.ClientExe, nsmgr);
            InsertClickOnceDependency(envConfig, dependencyList, lastPrerequisite, envConfig.ClientExe + ".config", nsmgr);
            InsertClickOnceDependency(envConfig, dependencyList, lastPrerequisite, Path.Combine("Configs", Path.GetFileNameWithoutExtension(envConfig.ClientExe) + ".xml"), nsmgr);

            // save to template
            doc.Save(GetManifestTemplateName(envConfig));
        }
 private void SetAppId(AppId other)
 {
     Id = (Id & ~(0xFFFFFFul << 0)) | (((ulong)(other) & 0xFFFFFFul) << 0);
 }
Example #5
0
 public int CompareTo(COMAppIDEntry other)
 {
     return(AppId.CompareTo(other.AppId));
 }
Example #6
0
        public async Task <ResultPage?> GetPageAsync(int page)
        {
            if (page <= 0)
            {
                throw new System.Exception("page should be > 0");
            }

            if (consumerApp == 0)
            {
                consumerApp = SteamClient.AppId;
            }
            if (creatorApp == 0)
            {
                creatorApp = consumerApp;
            }

            UGCQueryHandle_t handle;

            if (Files != null)
            {
                handle = SteamUGC.Internal.CreateQueryUGCDetailsRequest(Files, (uint)Files.Length);
            }
            else if (steamid.HasValue)
            {
                handle = SteamUGC.Internal.CreateQueryUserUGCRequest(steamid.Value.AccountId, userType, matchingType, userSort, creatorApp.Value, consumerApp.Value, (uint)page);
            }
            else
            {
                handle = SteamUGC.Internal.CreateQueryAllUGCRequest(queryType, matchingType, creatorApp.Value, consumerApp.Value, (uint)page);
            }

            ApplyReturns(handle);

            if (maxCacheAge.HasValue)
            {
                SteamUGC.Internal.SetAllowCachedResponse(handle, (uint)maxCacheAge.Value);
            }

            ApplyConstraints(handle);

            var result = await SteamUGC.Internal.SendQueryUGCRequest(handle);

            if (!result.HasValue)
            {
                return(null);
            }

            if (result.Value.Result != Steamworks.Result.OK)
            {
                return(null);
            }

            return(new ResultPage
            {
                Handle = result.Value.Handle,
                ResultCount = (int)result.Value.NumResultsReturned,
                TotalCount = (int)result.Value.TotalMatchingResults,
                CachedData = result.Value.CachedData,
                ReturnsKeyValueTags = WantsReturnKeyValueTags ?? false,
                ReturnsDefaultStats = WantsDefaultStats ?? true,                 //true by default
                ReturnsMetadata = WantsReturnMetadata ?? false,
                ReturnsChildren = WantsReturnChildren ?? false,
                ReturnsAdditionalPreviews = WantsReturnAdditionalPreviews ?? false,
            });
        }
Example #7
0
        public async Task <PublishResult> SubmitAsync(IProgress <float> progress = null)
        {
            var result = default(PublishResult);

            progress?.Report(0);

            if (consumerAppId == 0)
            {
                consumerAppId = SteamClient.AppId;
            }

            //
            // Item Create
            //
            if (creatingNew)
            {
                result.Result = Steamworks.Result.Fail;

                var created = await SteamUGC.Internal.CreateItem(consumerAppId, creatingType);

                if (!created.HasValue)
                {
                    return(result);
                }

                result.Result = created.Value.Result;

                if (result.Result != Steamworks.Result.OK)
                {
                    return(result);
                }

                FileId = created.Value.PublishedFileId;
                result.NeedsWorkshopAgreement = created.Value.UserNeedsToAcceptWorkshopLegalAgreement;
                result.FileId = FileId;
            }

            result.FileId = FileId;

            //
            // Item Update
            //
            {
                var handle = SteamUGC.Internal.StartItemUpdate(consumerAppId, FileId);
                if (handle == 0xffffffffffffffff)
                {
                    return(result);
                }

                if (Title != null)
                {
                    SteamUGC.Internal.SetItemTitle(handle, Title);
                }
                if (Description != null)
                {
                    SteamUGC.Internal.SetItemDescription(handle, Description);
                }
                if (MetaData != null)
                {
                    SteamUGC.Internal.SetItemMetadata(handle, MetaData);
                }
                if (Language != null)
                {
                    SteamUGC.Internal.SetItemUpdateLanguage(handle, Language);
                }
                if (ContentFolder != null)
                {
                    SteamUGC.Internal.SetItemContent(handle, ContentFolder.FullName);
                }
                if (PreviewFile != null)
                {
                    SteamUGC.Internal.SetItemPreview(handle, PreviewFile);
                }
                if (Visibility.HasValue)
                {
                    SteamUGC.Internal.SetItemVisibility(handle, Visibility.Value);
                }
                if (Tags != null && Tags.Count > 0)
                {
                    using (var a = SteamParamStringArray.From(Tags.ToArray()))
                    {
                        var val = a.Value;
                        SteamUGC.Internal.SetItemTags(handle, ref val);
                    }
                }

                result.Result = Steamworks.Result.Fail;

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

                var updating = SteamUGC.Internal.SubmitItemUpdate(handle, ChangeLog);

                while (!updating.IsCompleted)
                {
                    if (progress != null)
                    {
                        ulong total     = 0;
                        ulong processed = 0;

                        var r = SteamUGC.Internal.GetItemUpdateProgress(handle, ref processed, ref total);

                        switch (r)
                        {
                        case ItemUpdateStatus.PreparingConfig:
                        {
                            progress?.Report(0.1f);
                            break;
                        }

                        case ItemUpdateStatus.PreparingContent:
                        {
                            progress?.Report(0.2f);
                            break;
                        }

                        case ItemUpdateStatus.UploadingContent:
                        {
                            var uploaded = total > 0 ? ((float)processed / (float)total) : 0.0f;
                            progress?.Report(0.2f + uploaded * 0.7f);
                            break;
                        }

                        case ItemUpdateStatus.UploadingPreviewFile:
                        {
                            progress?.Report(8f);
                            break;
                        }

                        case ItemUpdateStatus.CommittingChanges:
                        {
                            progress?.Report(1);
                            break;
                        }
                        }
                    }

                    await Task.Delay(1000 / 60);
                }

                progress?.Report(1);

                var updated = updating.Result;

                if (!updated.HasValue)
                {
                    return(result);
                }

                result.Result = updated.Value.Result;

                if (result.Result != Steamworks.Result.OK)
                {
                    return(result);
                }

                result.NeedsWorkshopAgreement = updated.Value.UserNeedsToAcceptWorkshopLegalAgreement;
                result.FileId = FileId;
            }

            return(result);
        }
Example #8
0
 public override int GetHashCode()
 {
     return(AppId.GetHashCode() ^ PackageId.GetHashCode() ^ ContractId.GetHashCode() ^ Description.GetHashCode()
            ^ DisplayName.GetHashCode() ^ Icon.GetHashCode() ^ Vendor.GetHashCode() ^ COMUtilities.GetHashCodeDictionary(CustomProperties));
 }
Example #9
0
        /// <summary>
        /// Creates a web interface object connected to a specific Steam Web API interface endpoint
        /// </summary>
        /// <param name="appId">Indicates which app to use</param>
        /// <param name="httpClient">Custom http client injected with your customization (if necessary).
        /// If null, new instance is created with all defaults.</param>
        /// <typeparam name="T">Type of the web interface to create</typeparam>
        /// <returns>Instance of the web interface</returns>
        public T CreateSteamWebInterface <T>(AppId appId, HttpClient httpClient = null)
        {
            var steamWebRequest = CreateSteamWebRequest(httpClient);

            return((T)Activator.CreateInstance(typeof(T), mapper, steamWebRequest, appId, null));
        }
Example #10
0
        private static SendResult SendCCP(string url, string[] message, string receivers, AppId appId, string templateId, string signature)
        {
            NameValueCollection collection = new NameValueCollection();
            int index = 0;

            message.ForEach(p =>
            {
                collection.Add("ArrMessage[" + index + "]", p);
                index++;
            });
            collection.Add("Receivers", receivers);
            collection.Add("Signature", signature);
            collection.Add("TemplateId", templateId);
            collection.Add("AppId", appId.ToString());
            string json       = HttpUtility.PostHtml(url, collection, Encoding.UTF8);
            var    serializer = new JavaScriptSerializer();

            return(serializer.Deserialize <SendResult>(json));
        }
Example #11
0
 public Module(ModuleId moduleId, AppId appId, string title, string description, string iconClass, string url, int sequence)
     : this(moduleId, appId, title, description, iconClass, url, sequence,
            DateTime.UtcNow, DateTime.UtcNow, DateTime.MaxValue, DateTime.MaxValue)
 {
 }
        /// <summary>
        /// Sets property values
        /// </summary>
        /// <param name="context"></param>
        /// <param name="collection"></param>
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
        {
            string username            = (string)context["UserName"];
            bool   userIsAuthenticated = (bool)context["IsAuthenticated"];

            if (username == null || username.Length < 1 || collection.Count < 1)
            {
                return;
            }

            NpgsqlConnection conn   = null;
            NpgsqlDataReader reader = null;
            NpgsqlCommand    cmd    = null;

            try
            {
                bool anyItemsToSave = false;

                // First make sure we have at least one item to save
                foreach (SettingsPropertyValue pp in collection)
                {
                    if (pp.IsDirty)
                    {
                        if (!userIsAuthenticated)
                        {
                            bool allowAnonymous = (bool)pp.Property.Attributes["AllowAnonymous"];
                            if (!allowAnonymous)
                            {
                                continue;
                            }
                        }
                        anyItemsToSave = true;
                        break;
                    }
                }

                if (!anyItemsToSave)
                {
                    return;
                }

                conn = new NpgsqlConnection(_NpgsqlConnectionString);
                conn.Open();

                List <ProfileColumnData> columnData = new List <ProfileColumnData>(collection.Count);

                foreach (SettingsPropertyValue pp in collection)
                {
                    if (!userIsAuthenticated)
                    {
                        bool allowAnonymous = (bool)pp.Property.Attributes["AllowAnonymous"];
                        if (!allowAnonymous)
                        {
                            continue;
                        }
                    }

                    //Normal logic for original SQL provider
                    //if (!pp.IsDirty && pp.UsingDefaultValue) // Not fetched from DB and not written to

                    //Can eliminate unnecessary updates since we are using a table though
                    if (!pp.IsDirty)
                    {
                        continue;
                    }

                    string persistenceData = pp.Property.Attributes["CustomProviderData"] as string;
                    // If we can't find the table/column info we will ignore this data
                    if (String.IsNullOrEmpty(persistenceData))
                    {
                        continue;
                    }
                    string[] chunk = persistenceData.Split(new char[] { ';' });
                    if (chunk.Length != 2)
                    {
                        continue;
                    }
                    string       columnName = chunk[0];
                    NpgsqlDbType datatype   = (NpgsqlDbType)Enum.Parse(typeof(NpgsqlDbType), chunk[1], true);

                    object value = null;

                    if (pp.Deserialized && pp.PropertyValue == null)
                    {
                        // is value null?
                        value = DBNull.Value;
                    }
                    else
                    {
                        value = pp.PropertyValue;
                    }

                    columnData.Add(new ProfileColumnData(columnName, pp, value, datatype));
                }

                // Figure out userid, if we don't find a userid, go ahead and create a user in the aspnetUsers table
                Guid   userId    = Guid.Empty;
                string tmpUserId = null;
                cmd =
                    new NpgsqlCommand(
                        string.Format(
                            "SELECT u.UserId FROM vw_aspnet_Users u WHERE u.ApplicationId = '{0}' AND u.LoweredUserName = LOWER(@Username)",
                            AppId), conn);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@Username", NpgsqlDbType.Text, 255).Value = username;
                try
                {
                    reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        tmpUserId = reader.GetString(0);
                        if (!string.IsNullOrEmpty(tmpUserId)) // != null && tmpUserId != "")
                        {
                            userId = new Guid(tmpUserId);
                        }
                        else
                        {
                            userId = Guid.NewGuid();
                        }
                    }
                    else
                    {
                        reader.Close();
                        cmd.Dispose();
                        reader = null;

                        cmd =
                            new NpgsqlCommand(
                                " INSERT INTO aspnet_Users (ApplicationId, UserId, UserName, LoweredUserName, IsAnonymous, LastActivityDate) " +
                                " VALUES (@ApplicationId, @UserId, @UserName, LOWER(@UserName), @IsUserAnonymous, @LastActivityDate) ", conn);
                        userId          = Guid.NewGuid();
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.Add("@UserId", NpgsqlDbType.Text, 36).Value            = userId.ToString();
                        cmd.Parameters.Add("@ApplicationId", NpgsqlDbType.Text, 36).Value     = AppId.ToString();
                        cmd.Parameters.Add("@UserName", NpgsqlDbType.Text, 255).Value         = username;
                        cmd.Parameters.Add("@IsUserAnonymous", NpgsqlDbType.Boolean).Value    = !userIsAuthenticated;
                        cmd.Parameters.Add("@LastActivityDate", NpgsqlDbType.Timestamp).Value = DateTime.UtcNow;

                        cmd.ExecuteBlind();
                    }
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                        reader = null;
                    }
                    cmd.Dispose();
                }

                // Figure out if the row already exists in the table and use appropriate SELECT/UPDATE
                cmd             = new NpgsqlCommand("SELECT * FROM " + _table + " WHERE UserId = @UserId", conn);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add("@UserId", NpgsqlDbType.Text, 36).Value = userId.ToString();
                NpgsqlDataReader readerSelect = null;
                bool             IfExists     = false;
                try
                {
                    using (readerSelect = cmd.ExecuteReader(CommandBehavior.SingleRow))
                    {
                        if (readerSelect.HasRows)
                        {
                            // IF EXISTS (SELECT * FROM aspnet_users WHERE UserId = '')
                            IfExists = true;
                        }
                        else
                        {
                            IfExists = false;
                        }
                        readerSelect.Close();
                    }
                }
                catch (NpgsqlException)
                {
                }
                finally
                {
                    if (readerSelect != null)
                    {
                        readerSelect.Close();
                    }
                }

                cmd = new NpgsqlCommand(String.Empty, conn);
                StringBuilder NpgsqlCommand = new StringBuilder();
                // Build up strings used in the query
                StringBuilder columnStr = new StringBuilder();
                StringBuilder valueStr  = new StringBuilder();
                StringBuilder setStr    = new StringBuilder();
                int           count     = 0;
                foreach (ProfileColumnData data in columnData)
                {
                    columnStr.Append(", ");
                    valueStr.Append(", ");
                    columnStr.Append(data.ColumnName);
                    string valueParam = "@Value" + count;
                    valueStr.Append(valueParam);
                    cmd.Parameters.Add(valueParam, data.Value);

                    if (data.DataType != NpgsqlDbType.Timestamp)
                    {
                        if (count > 0)
                        {
                            setStr.Append(",");
                        }
                        setStr.Append(data.ColumnName);
                        setStr.Append("=");
                        setStr.Append(valueParam);
                    }

                    ++count;
                }
                columnStr.Append(",LastUpdatedDate ");
                valueStr.Append(",@LastUpdatedDate");
                setStr.Append(",LastUpdatedDate=@LastUpdatedDate");
                cmd.Parameters.Add("@LastUpdatedDate", NpgsqlDbType.Timestamp).Value = DateTime.UtcNow;

                if (setStr.ToString().StartsWith(","))
                {
                    setStr.Remove(0, 1);
                }

                if (IfExists)
                {
                    NpgsqlCommand.Append("UPDATE ").Append(_table).Append(" SET ").Append(setStr.ToString());
                    NpgsqlCommand.Append(" WHERE UserId = '").Append(userId).Append("'");
                }
                else
                {
                    NpgsqlCommand.Append("INSERT INTO ").Append(_table).Append(" (UserId").Append(columnStr.ToString());
                    NpgsqlCommand.Append(") VALUES ('").Append(userId).Append("'").Append(valueStr.ToString()).Append(")");
                }

                cmd.CommandText = NpgsqlCommand.ToString();
                cmd.CommandType = CommandType.Text;

                cmd.ExecuteBlind();

                // Need to close reader before we try to update
                if (reader != null)
                {
                    reader.Close();
                    reader = null;
                }

                UpdateLastActivityDate(conn, userId);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (cmd != null)
                {
                    cmd.Dispose();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
        private ActionResult ExportToCsv(List <MessageView> wechatFollowReportList)
        {
            string[] headLine = { "Id", "Title", "APPName", "ReadCount", "ThumbsUpCount", "PublishDate" };
            var      csv      = new CsvSerializer <MessageView> {
                UseLineNumbers = false
            };
            var    sRet          = csv.SerializeStream(wechatFollowReportList, headLine);
            var    channelConfig = CommonService.GetAppList().FirstOrDefault(x => x.WeixinAppId.Equals(AppId.ToString(CultureInfo.InvariantCulture)));
            string fileHeadName  = channelConfig == null?AppId.ToString(CultureInfo.InvariantCulture) : channelConfig.AppName;

            string fileName = fileHeadName + "_Message_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".csv";

            return(File(sRet, "text/comma-separated-values", fileName));
        }
        /// <summary>
        /// CSV文件出力
        /// </summary>
        /// <param name="title">新闻标题</param>
        /// <param name="pulishDate">发布时间</param>
        /// <returns></returns>
        public ActionResult ExportCSV(string title, string pulishDate, Expression <Func <Message, bool> > predicate)
        {
            //Expression<Func<Message, bool>> predicate = x => x.AppId == AppId && x.IsDeleted == false;

            if (!string.IsNullOrEmpty(title))
            {
                title     = title.Trim().ToLower();
                predicate = predicate.AndAlso(a => a.Title.ToLower().Contains(title));
            }

            if (!string.IsNullOrEmpty(pulishDate))
            {
                DateTime condDate    = Convert.ToDateTime(pulishDate);
                DateTime condDateEnd = condDate.AddDays(1);
                predicate = predicate.AndAlso(x => x.PublishDate >= condDate && x.PublishDate <= condDateEnd);
            }

            // APP列表
            var appInfo = CommonService.lstSysWeChatConfig.FirstOrDefault(a => a.WeixinAppId == AppId.ToString());

            List <MessageView> reportList = _messageService.GetList <MessageView>(predicate).OrderByDescending(x => x.Id).ToList();

            var ids = reportList.Select(x => x.Id).ToList();
            var lst = _articleThumbsUpService.Repository.Entities.Where(x => ids.Contains(x.ArticleID) &&
                                                                        x.IsDeleted != true &&
                                                                        x.Type == ThumbupType.Message.ToString()).Select(x => x.ArticleID).ToList();

            reportList.ForEach(x =>
            {
                x.ThumbsUpCount = lst.Count(z => z == x.Id);
            });

            if (appInfo != null)
            {
                foreach (MessageView item in reportList)
                {
                    item.APPName = appInfo.AppName;
                }
            }

            return(ExportToCsv(reportList));
        }
Example #15
0
        public async Task <IList <PublishedFileDetails> > GetPublishedFilesForAppIdRawAsync(AppId appId, CancellationToken?cancellationToken = null)
        {
            cancellationToken = cancellationToken ?? CancellationToken.None;

            string paginationCursor           = "*";
            List <PublishedFileDetails> items = new List <PublishedFileDetails>();

            while (!cancellationToken.Value.IsCancellationRequested)
            {
                var requestDetails = new CPublishedFile_QueryFiles_Request
                {
                    query_type    = (uint)SteamKit.EPublishedFileQueryType.RankedByPublicationDate,
                    cursor        = paginationCursor,
                    creator_appid = appId,
                    appid         = appId,
                    numperpage    = 100,

                    return_vote_data         = true,
                    return_children          = true,
                    return_for_sale_data     = true,
                    return_kv_tags           = true,
                    return_metadata          = true,
                    return_tags              = true,
                    return_previews          = true,
                    return_details           = true,
                    return_short_description = true,
                };

                var methodResponse = await PublishedFileService.SendMessage(api => api.QueryFiles(requestDetails));

                var returnedItems = methodResponse.GetDeserializedResponse <CPublishedFile_QueryFiles_Response>();

                items.AddRange(returnedItems.publishedfiledetails);
                paginationCursor = returnedItems.next_cursor;

                if (returnedItems.publishedfiledetails.Count == 0)
                {
                    break;
                }
            }

            return(items);
        }
Example #16
0
 public bool Connect(bool createDefaultSession = false)
 {
     try
     {
         var appList       = GetApps();
         var appIdentifier = appList.Where(c => c.AppId == AppId.ToString()).SingleOrDefault() ?? null;
         if (appIdentifier == null)
         {
             appIdentifier = appList.Where(c => c.AppName == AppName).SingleOrDefault();
         }
         Identifier = appIdentifier ?? throw new Exception($"No App with the id {AppId.ToString()} oder name {AppName} found.");
         if (createDefaultSession)
         {
             GetDefaultSession();
         }
         else
         {
             GetFreeSession();
         }
         return(true);
     }
     catch (Exception ex)
     {
         if (IsServerConnection)
         {
             logger.Error(ex, $"The connection to Qlik Sense Server with app \"{AppId}\" could not be established.");
         }
         else
         {
             logger.Error(ex, $"The connection to Qlik Sense Desktop with app \"{AppName}\" could not be established.");
         }
         return(false);
     }
 }
Example #17
0
 public Base()
 {
     AppId = SteamClient.AppId;             // Default AppId is this
 }
Example #18
0
 public PermissionAdded(AppId appId, PermissionId permissionId)
 {
     AppId        = appId;
     PermissionId = permissionId;
 }
Example #19
0
 public override int GetHashCode()
 {
     return(AppId.GetHashCode());
 }
Example #20
0
 public Editor ForAppId(AppId id)
 {
     this.consumerAppId = id; return(this);
 }
        /// <summary>
        /// After the Update button is clicked, updates the template or creates a new one,
        /// depending if in edit mode or not.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            var attributeSetId = ctrContentType.ContentTypeID.HasValue && ctrContentType.ContentTypeID > 0 ? ctrContentType.ContentTypeID.Value : new int?();

            // Get a new template if the temlpate does not exist yet, else take existing
            Template = ModeIsEdit ? Template : Sexy.TemplateContext.GetNewTemplate(AppId.Value);

            Template.PortalID         = this.PortalId;
            Template.AttributeSetID   = attributeSetId;
            Template.DemoEntityID     = ctrContentType.DemoEntityID;
            Template.Location         = ddlTemplateLocations.SelectedValue;
            Template.Type             = ddlTemplateTypes.SelectedValue;
            Template.PipelineEntityID = ddlDataPipeline.SelectedValue == "0" ? (int?)null : int.Parse(ddlDataPipeline.SelectedValue);
            Template.ViewNameInUrl    = txtViewNameInUrl.Text;
            Template.SysModifiedBy    = UserId;
            Template.SysModified      = DateTime.Now;
            Template.Name             = txtTemplateName.Text;
            Template.Script           = "";
            Template.IsHidden         = chkHidden.Checked;
            Template.UseForList       = chkEnableList.Checked;
            Template.AppID            = AppId.Value;
            Template.PublishData      = chkPublishSource.Checked;
            Template.StreamsToPublish = txtPublishStreams.Text;

            if (pnlSelectTemplateFile.Visible)
            {
                Template.Path = ddlTemplateFiles.SelectedValue;
            }
            else
            {
                SexyUncached.CreateTemplateFileIfNotExists(txtTemplateFileName.Text, Template, Server, LocalizeString("NewTemplateFile.DefaultText"));
            }

            if (ModeIsEdit)
            {
                SexyUncached.TemplateContext.UpdateTemplate(Template);
            }
            else
            {
                Template.SysCreatedBy = UserId;
                SexyUncached.TemplateContext.AddTemplate(Template);
            }

            if (!chkSeparateContentPresentation.Checked)
            {
                ctrPresentationType.ContentTypeID = new int?();
            }

            // Add template configuration entities for presentation, list header content type, list content, etc.
            SexyUncached.CreateOrUpdateTemplateDefault(Template.TemplateID, ContentGroupItemType.Presentation.ToString("F"), ctrPresentationType.ContentTypeID, ctrPresentationType.DemoEntityID);
            SexyUncached.CreateOrUpdateTemplateDefault(Template.TemplateID, ContentGroupItemType.ListContent.ToString("F"), ctrListContentType.ContentTypeID, ctrListContentType.DemoEntityID);
            SexyUncached.CreateOrUpdateTemplateDefault(Template.TemplateID, ContentGroupItemType.ListPresentation.ToString("F"), ctrListPresentationType.ContentTypeID, ctrListPresentationType.DemoEntityID);

            // Redirect to the manage templates control
            string RedirectUrl = UrlUtils.PopUpUrl(DotNetNuke.Common.Globals.NavigateURL(SexyContent.ControlKeys.ManageTemplates, "mid", ModuleId.ToString(), SexyContent.AppIDString, AppId.ToString()), this, PortalSettings, false, true);

            Response.Redirect(RedirectUrl);
        }
Example #22
0
        private void LoadFromKey(RegistryKey key)
        {
            RunAs = key.GetValue("RunAs") as string;
            string name = key.GetValue(null) as string;

            if (!String.IsNullOrWhiteSpace(name))
            {
                Name = name.ToString();
            }
            else
            {
                Name = AppId.FormatGuidDefault();
            }

            AccessPermission = ConvertSD(key.GetValue("AccessPermission") as byte[]);
            LaunchPermission = ConvertSD(key.GetValue("LaunchPermission") as byte[]);

            DllSurrogate = key.GetValue("DllSurrogate") as string;
            if (DllSurrogate != null)
            {
                if (String.IsNullOrWhiteSpace(DllSurrogate))
                {
                    DllSurrogate = "dllhost.exe";
                }
                else
                {
                    string dllexe = key.GetValue("DllSurrogateExecutable") as string;
                    if (!String.IsNullOrWhiteSpace(dllexe))
                    {
                        DllSurrogate = dllexe;
                    }
                }
            }
            else
            {
                DllSurrogate = String.Empty;
            }

            object flags = key.GetValue("AppIDFlags");

            if (flags != null)
            {
                Flags = (COMAppIDFlags)flags;
            }

            string local_service = key.GetValue("LocalService") as string;

            if (!String.IsNullOrWhiteSpace(local_service))
            {
                try
                {
                    using (RegistryKey serviceKey = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Services\" + local_service))
                    {
                        using (ServiceController service = new ServiceController(local_service))
                        {
                            LocalService = new COMAppIDServiceEntry(serviceKey, service);
                        }
                    }
                }
                catch
                {
                }
            }

            if (String.IsNullOrWhiteSpace(RunAs))
            {
                RunAs = String.Empty;
            }

            object rotflags = key.GetValue("ROTFlags");

            if (rotflags != null && rotflags is int)
            {
                RotFlags = (COMAppIDRotFlags)rotflags;
            }
        }
        public async Task <PublishResult> SubmitAsync(IProgress <float> progress = null)
        {
            var result = default(PublishResult);

            progress?.Report(0);

            if (consumerAppId == 0)
            {
                consumerAppId = SteamClient.AppId;
            }

            //
            // Checks
            //
            if (ContentFolder != null)
            {
                if (!System.IO.Directory.Exists(ContentFolder.FullName))
                {
                    throw new System.Exception($"UgcEditor - Content Folder doesn't exist ({ContentFolder.FullName})");
                }

                if (!ContentFolder.EnumerateFiles("*", System.IO.SearchOption.AllDirectories).Any())
                {
                    throw new System.Exception($"UgcEditor - Content Folder is empty");
                }
            }


            //
            // Item Create
            //
            if (creatingNew)
            {
                result.Result = Steamworks.Result.Fail;

                var created = await SteamUGC.Internal.CreateItem(consumerAppId, creatingType);

                if (!created.HasValue)
                {
                    return(result);
                }

                result.Result = created.Value.Result;

                if (result.Result != Steamworks.Result.OK)
                {
                    return(result);
                }

                fileId = created.Value.PublishedFileId;
                result.NeedsWorkshopAgreement = created.Value.UserNeedsToAcceptWorkshopLegalAgreement;
                result.FileId = fileId;
            }


            result.FileId = fileId;

            //
            // Item Update
            //
            {
                var handle = SteamUGC.Internal.StartItemUpdate(consumerAppId, fileId);
                if (handle == 0xffffffffffffffff)
                {
                    return(result);
                }

                if (Title != null)
                {
                    SteamUGC.Internal.SetItemTitle(handle, Title);
                }
                if (Description != null)
                {
                    SteamUGC.Internal.SetItemDescription(handle, Description);
                }
                if (MetaData != null)
                {
                    SteamUGC.Internal.SetItemMetadata(handle, MetaData);
                }
                if (Language != null)
                {
                    SteamUGC.Internal.SetItemUpdateLanguage(handle, Language);
                }
                if (ContentFolder != null)
                {
                    SteamUGC.Internal.SetItemContent(handle, ContentFolder.FullName);
                }
                if (PreviewFile != null)
                {
                    SteamUGC.Internal.SetItemPreview(handle, PreviewFile);
                }
                if (Visibility.HasValue)
                {
                    SteamUGC.Internal.SetItemVisibility(handle, Visibility.Value);
                }
                if (Tags != null && Tags.Count > 0)
                {
                    using (var a = SteamParamStringArray.From(Tags.ToArray()))
                    {
                        var val = a.Value;
                        SteamUGC.Internal.SetItemTags(handle, ref val);
                    }
                }

                if (KeyValueTagsToRemove != null)
                {
                    foreach (var key in KeyValueTagsToRemove)
                    {
                        SteamUGC.Internal.RemoveItemKeyValueTags(handle, key);
                    }
                }

                if (KeyValueTags != null)
                {
                    foreach (var keyWithValues in KeyValueTags)
                    {
                        var key = keyWithValues.Key;
                        foreach (var value in keyWithValues.Value)
                        {
                            SteamUGC.Internal.AddItemKeyValueTag(handle, key, value);
                        }
                    }
                }

                result.Result = Steamworks.Result.Fail;

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

                var updating = SteamUGC.Internal.SubmitItemUpdate(handle, ChangeLog);

                while (!updating.IsCompleted)
                {
                    if (progress != null)
                    {
                        ulong total     = 0;
                        ulong processed = 0;

                        var r = SteamUGC.Internal.GetItemUpdateProgress(handle, ref processed, ref total);

                        switch (r)
                        {
                        case ItemUpdateStatus.PreparingConfig:
                        {
                            progress?.Report(0.1f);
                            break;
                        }

                        case ItemUpdateStatus.PreparingContent:
                        {
                            progress?.Report(0.2f);
                            break;
                        }

                        case ItemUpdateStatus.UploadingContent:
                        {
                            var uploaded = total > 0 ? ((float)processed / (float)total) : 0.0f;
                            progress?.Report(0.2f + uploaded * 0.7f);
                            break;
                        }

                        case ItemUpdateStatus.UploadingPreviewFile:
                        {
                            progress?.Report(0.8f);
                            break;
                        }

                        case ItemUpdateStatus.CommittingChanges:
                        {
                            progress?.Report(1);
                            break;
                        }
                        }
                    }

                    await Task.Delay(1000 / 60);
                }

                progress?.Report(1);

                var updated = updating.GetResult();

                if (!updated.HasValue)
                {
                    return(result);
                }

                result.Result = updated.Value.Result;

                if (result.Result != Steamworks.Result.OK)
                {
                    return(result);
                }

                result.NeedsWorkshopAgreement = updated.Value.UserNeedsToAcceptWorkshopLegalAgreement;
                result.FileId = fileId;
            }

            return(result);
        }
 public GameId(AppId appId)
 {
     Id = 0;
     SetAppId(appId);
 }
 public SteamRequiredLicenseNotFoundException(AppId appId) : base($"The Steam user cannot access this content as it does not own a " +
                                                                  $"license for app id {appId} and no free one could be optained either.")
 {
 }
Example #26
0
 private string GetJobKey(IJobDetail jobDetail)
 {
     return(AppId.Split('-')[0] + "." + jobDetail.Key.Group + "." + jobDetail.Key.Name);
 }
Example #27
0
 public override int GetHashCode() => (AppId != null ? AppId.GetHashCode() : 0);
Example #28
0
        private static System.Reflection.Assembly FillAppId(EnvConfig envConfig, XmlNode assemblyIdentity, AppId appId)
        {
            var client = System.Reflection.Assembly.ReflectionOnlyLoadFrom(envConfig.ClientExe);

            FillClickOnceAssemblyId(client, assemblyIdentity);
            // this seems to be a constant
            SetOrReplaceAttribute(assemblyIdentity, "type", null, "win32");

            // asmv1 wants a filename, not an assembly name
            SetOrReplaceAttribute(assemblyIdentity, "name", null, Path.GetFileName(envConfig.ClientExe));

            SetOrReplaceAttribute(assemblyIdentity, "version", null, appId.version);
            SetOrReplaceAttribute(assemblyIdentity, "publicKeyToken", null, appId.publicKeyToken);
            return client;
        }
Example #29
0
 public bool IsValid()
 {
     return(!AppId.IsNullOrWhiteSpace() && !AppSecret.IsNullOrWhiteSpace());
 }
Example #30
0
        private static void SignXmlSec1(EnvConfig envConfig, string templateName, string outputName, AppId appId)
        {
            Program.LogAction("signing with xmlsec1: [{0}] => [{1}]", templateName, outputName);

            // load manifest input xml
            var docTemplate = new XmlDocument();
            docTemplate.Load(templateName);
            var nsmgr = CreateDefaultXmlNsmgr(docTemplate);

            // insert publisher identity
            var pfx = UnlockPfx(File.ReadAllBytes(envConfig.ClickOnce.KeyFile));
            var cert = pfx.Certificates.Cast<X509Certificate>().Single();
            var publisherName = cert.SubjectName;
            // as described on http://msdn.microsoft.com/en-us/library/dd996956.aspx
            var issuerKeyHash = FormatKey(_sha1.ComputeHash(cert.PublicKey));

            var publisherIdentity = docTemplate.CreateElement("publisherIdentity", ASMv2_NS);
            SetOrReplaceAttribute(publisherIdentity, "name", null, publisherName);
            SetOrReplaceAttribute(publisherIdentity, "issuerKeyHash", null, issuerKeyHash);

            docTemplate.ChildNodes.OfType<XmlElement>().Last().AppendChild(publisherIdentity);

            var fusionTemplateName = templateName + ".fusion";
            docTemplate.Save(fusionTemplateName);

            //
            // Calculate ManifestInformation Hash
            // ==================================
            // The Fusion XML engine is always preserving whitespace, therefore we need to
            // use a specially configured XmlDocument to normalize and sign the Manifest.
            //
            byte[] hash;
            {
                var fusionDoc = new XmlDocument();
                fusionDoc.PreserveWhitespace = true;
                fusionDoc.Load(fusionTemplateName);

                var transform = new XmlDsigExcC14NTransform();
                transform.LoadInput(fusionDoc);
                hash = _sha1.ComputeHash((MemoryStream)transform.GetOutput());
            }

            // Load SignatureBlock into DOM
            var signatureTemplate = LoadXmlFromResource("PrepareEnv.Templates.SignatureBlock.xml");
            foreach (XmlNode sigNode in signatureTemplate.DocumentElement.ChildNodes)
            {
                var newChild = docTemplate.ImportNode(sigNode, deep: true);
                docTemplate.DocumentElement.AppendChild(newChild);
                foreach (XmlNode assemblyId in newChild.SelectNodes("//as:assemblyIdentity", nsmgr))
                {
                    // authenticode assemblyIdentity looks like asmv1:assemblyIdentity
                    FillAppId(envConfig, assemblyId, appId);
                }
            }

            // Set ManifestInformation Hash
            var manifestInfo = docTemplate.SelectSingleNode("//as:ManifestInformation", nsmgr);
            SetOrReplaceAttribute(manifestInfo, "Hash", null, FormatKey(hash));

            // Set AuthenticodePublisher's SubjectName
            var subjectName = docTemplate.SelectSingleNode("//as:AuthenticodePublisher/as:X509SubjectName", nsmgr);
            subjectName.InnerText = publisherName;

            // Sign everything
            Program.LogDetail("saving to xmlsec1 template: [{0}]", templateName + ".xmlsec1");
            docTemplate.Save(templateName + ".xmlsec1");

            var pw = _passphrase == null ? string.Empty : string.Format("--pwd \"{0}\"", _passphrase);

            // resign manifest RelData
            var relDataArgs = string.Format("--sign {0} {1} {2} --node-xpath \"//*[local-name()='RelData']\" --enabled-key-data rsa,x509 --output \"{3}.reldata\" \"{4}.xmlsec1\"",
                                            pw,
                                            envConfig.ClickOnce.KeyFile.EndsWith("pfx") ? "--pkcs12" : "--privkey-pem",
                                            envConfig.ClickOnce.KeyFile,
                                            outputName,
                                            templateName);
            Program.LogDetail("signing reldata to [{0}.reldata]", outputName);
            var proc = Process.Start(new ProcessStartInfo("xmlsec1", relDataArgs) { UseShellExecute = false });
            proc.WaitForExit();
            if (proc.ExitCode != 0)
            {
                throw new InvalidOperationException(string.Format("xmlsec1 complained about {0}", relDataArgs));
            }

            // resign complete manifest
            var finalArgs = string.Format("--sign {0} {1} {2} --enabled-key-data rsa,x509 --output \"{3}\" \"{3}.reldata\"",
                                          pw,
                                          envConfig.ClickOnce.KeyFile.EndsWith("pfx") ? "--pkcs12" : "--privkey-pem",
                                          envConfig.ClickOnce.KeyFile,
                                          outputName);
            Program.LogDetail("signing final to : [{0}]", outputName);
            proc = Process.Start(new ProcessStartInfo("xmlsec1", finalArgs) { UseShellExecute = false });
            proc.WaitForExit();
            if (proc.ExitCode != 0)
            {
                throw new InvalidOperationException(string.Format("xmlsec1 complained about {0}", finalArgs));
            }
        }
 public SteamInvalidBranchPasswordException(AppId appId, DepotId depotId, string branch, string password, Exception innerException = null) : base($"Invalid password = "******"'{password}' for branch = {branch} of app id = {appId}, depot id = {depotId}{(innerException != null ? ". View the inner exception for more details." : "")}", innerException)
 {
 }
Example #32
0
        private static void CreateClickOnceAppplication(EnvConfig envConfig, AppId appId)
        {
            var doc = LoadXmlFromResource("PrepareEnv.Templates.ClickOnce.application.xml");
            var nsmgr = CreateDefaultXmlNsmgr(doc);

            // primary asmv1:assemblyIdentity
            var assemblyIdentity1 = doc.SelectSingleNode("/asmv1:assembly/asmv1:assemblyIdentity", nsmgr);
            // name of the application manifest
            SetOrReplaceAttribute(assemblyIdentity1, "name", null, Path.GetFileName(GetAppName(envConfig)));
            // deployment version
            SetOrReplaceAttribute(assemblyIdentity1, "version", null, envConfig.ClickOnce.DeploymentVersion);
            // key token of the signing key
            SetOrReplaceAttribute(assemblyIdentity1, "publicKeyToken", null, FormatKey(PublicKeyTokenFromPfx(envConfig.ClickOnce.KeyFile)));
            // from the underlying .exe
            SetOrReplaceAttribute(assemblyIdentity1, "language", null, "neutral");
            SetOrReplaceAttribute(assemblyIdentity1, "processorArchitecture", null, "msil");

            // application description
            var description = doc.SelectSingleNode("/asmv1:assembly/asmv1:description", nsmgr);
            SetOrReplaceAttribute(description, "publisher", ASMv2_NS, envConfig.ClickOnce.Publisher);
            SetOrReplaceAttribute(description, "product", ASMv2_NS, envConfig.ClickOnce.Product);
            if (!string.IsNullOrEmpty(envConfig.ClickOnce.SuiteName))
            {
                SetOrReplaceAttribute(description, "suiteName", null, envConfig.ClickOnce.SuiteName);
            }
            if (!string.IsNullOrEmpty(envConfig.ClickOnce.SupportUrl))
            {
                SetOrReplaceAttribute(description, "supportUrl", null, envConfig.ClickOnce.SupportUrl);
            }
            if (!string.IsNullOrEmpty(envConfig.ClickOnce.ErrorReportUrl))
            {
                SetOrReplaceAttribute(description, "errorReportUrl", null, envConfig.ClickOnce.ErrorReportUrl);
            }

            // deployment options
            var deploymentProvider = doc.SelectSingleNode("/asmv1:assembly/asmv2:deployment/asmv2:deploymentProvider", nsmgr);
            SetOrReplaceAttribute(deploymentProvider, "codebase", null, envConfig.ClickOnce.UpdateUrl);

            // insert manifest file
            var dependencyList = doc.SelectSingleNode("/asmv1:assembly", nsmgr);
            var lastPrerequisite = doc.SelectNodes("/asmv1:assembly/co.v2:compatibleFrameworks", nsmgr).OfType<XmlNode>().Last();
            InsertClickOnceDependency(envConfig, dependencyList, lastPrerequisite, GetManifestName(envConfig), nsmgr);

            // save to template
            doc.Save(GetAppTemplateName(envConfig));
        }
Example #33
0
 // wrapper pour les tâches asynchrones d'appel aux API Highlight
 public HighlightAppInfoTask(Uri baseUrl, AppId app, Func <Task <AppInfo> > taskBuilder) : base(taskBuilder)
 {
     App     = app;
     BaseUrl = baseUrl;
 }