コード例 #1
0
        public static void Run()
        {
            // ExStart:1
            CellsApi   cellsApi   = new CellsApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);
            StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);

            String fileName  = "Sample_Test_Book.xls";
            String sheetName = "Sheet1";
            String formula   = "SUM(A5:A10)";
            String storage   = "";
            String folder    = "";

            try
            {
                // Upload source file to aspose cloud storage
                storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName));

                // Invoke Aspose.Cells Cloud SDK API to calculate formula in a worksheet
                SingleValueResponse apiResponse = cellsApi.GetWorkSheetCalculateFormula(fileName, sheetName, formula, storage, folder);

                if (apiResponse != null && apiResponse.Status.Equals("OK"))
                {
                    SingleValue resultValue = apiResponse.Value;
                    Console.WriteLine("Calculated value:" + resultValue.Value);
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }
コード例 #2
0
ファイル: ChannelManager.cs プロジェクト: qvazzler/Lyralei
        private int PopChannel(string StoredChannelUniqueId, int?ChannelId, int?ChannelParentId = null, int?ChannelOrder = null)
        {
            using (var db = new CoreContext())
            {
                // Remove the stored channel
                Models.StoredChannels storedChannel;

                if (ChannelId != null)
                {
                    storedChannel = db.StoredChannels.SingleOrDefault(channel => channel.ChannelId == ChannelId && channel.SubscriberId == this.Subscriber.SubscriberId);
                }
                else
                {
                    storedChannel = db.StoredChannels.SingleOrDefault(channel => channel.StoredChannelUniqueId == StoredChannelUniqueId && channel.SubscriberId == this.Subscriber.SubscriberId);
                }

                if (storedChannel == null)
                {
                    throw new Exception("Stored channel does not exist");
                }

                db.Remove(storedChannel);

                // Create the new channel
                var channelMod = storedChannel.ToChannelModification();

                if (channelMod.IconId == 0)
                {
                    channelMod.IconId = null;
                }

                if (ChannelParentId != null)
                {
                    channelMod.ParentChannelId = (uint?)ChannelParentId;
                }

                if (ChannelOrder != null)
                {
                    channelMod.ChannelOrder = (uint?)ChannelOrder;
                }

                SingleValueResponse <uint?> creationResponse = null;

                try
                {
                    //TODO: Fix the incorrect input format bug in ts3querylib
                    creationResponse = ServerQueryConnection.QueryRunner.CreateChannel(channelMod);

                    if (creationResponse.IsErroneous)
                    {
                        throw new Exception("Could not pop stored channel: " + creationResponse.ResponseText + " (" + creationResponse.ErrorMessage + ")");
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message != "Input string was not in a correct format.")
                    {
                        // Uh oh, something else happened
                        throw ex;
                    }
                }

                if (creationResponse.Value == null)
                {
                    throw new Exception("Could not pop stored channel, no result given.");
                }

                // Save changes
                db.SaveChanges();
                return((int)creationResponse.Value); // Return the new channel id
            }
        }