Ejemplo n.º 1
0
        private void checkSSIDPassword()
        {
            Excel.Application exApp = Globals.ThisAddIn.Application as Excel.Application;
            Excel.Workbook wb = exApp.ActiveWorkbook as Excel.Workbook;
            Channel ch = new Channel();

            if (!TokenStore.checkTokenInStore())
            {
                LoginForm frm = new LoginForm();
                frm.Show();
            }
            else
            {
                ch.setAuthToken(TokenStore.getTokenFromStore());
            }

            if (ch.checkSpreadSheetID(wb) == "0")
            {
                string id = ch.getSpreadSheetID(wb.Name.ToString());
                spreadSheetID = Convert.ToInt32(id);

                //write to wb property when a new ID is obtained
                Microsoft.Office.Core.DocumentProperties properties;
                properties = (Office.DocumentProperties)wb.CustomDocumentProperties;

                properties.Add("Excalibur ID", false,
                   Microsoft.Office.Core.MsoDocProperties.msoPropertyTypeString, id);
            }
            else
            {
                string id = ch.checkSpreadSheetID(wb);
                spreadSheetID = Convert.ToInt32(id);

            }
        }
Ejemplo n.º 2
0
        private void InitializePubComboBox()
        {
            Channel ch = new Channel();
            string token = TokenStore.getTokenFromStore();
            ch.setAuthToken(token);
            JArray d = ch.getAllBroadcastsChannels();

            //Need User ID to send into filterPermittedChannels
            JArray datafeed = ch.filterChannelsInBroadcast(d);
            if (datafeed.ToString() != "[]")
            {
                foreach (dynamic data in datafeed)
                {
                    foreach (dynamic c in data.channels)
                    {
                        pubComboBox.Items.Add(c.id.ToString() + "-" + c.description.ToString());
                    }
                }
            }
            else
            {
                pubComboBox.Items.Add("No data in the channel");
                pubComboBox.SelectedIndex = 0;
            }
        }
Ejemplo n.º 3
0
 public PubForm()
 {
     ch = new Channel();
     InitializeComponent();
     checkSSIDPassword();
     InitializePermittedBroadcastsComboBox();
 }
Ejemplo n.º 4
0
        public void GetAllChannelsTest()
        {
            using (ShimsContext.Create())
            {
                var responseStream = new FileStream("Fixtures/v1.channels.index.response", FileMode.Open);
                var responseShim = new ShimHttpWebResponse()
                {
                     GetResponseStream = () => responseStream
                };
                String actualMethod = "";
                var requestShim = new ShimHttpWebRequest()
                {
                    MethodSetString = (method) => { actualMethod = method; },
                    GetResponse = () => responseShim
                };

                String actualURL = "";
                ShimWebRequest.CreateString = (url) =>
                {
                    actualURL = url;
                    return requestShim;
                };

                Channel ch = new Channel();
                JArray json = ch.getAllBroadcastsChannels();

                StringAssert.AreEqualIgnoringCase("GET", actualMethod);
                StringAssert.AreEqualIgnoringCase("http://panoply-staging.herokuapp.com/api/channels.json", actualURL);
                Assert.AreEqual(2, json.Count);
            }
        }
Ejemplo n.º 5
0
 public SubForm()
 {
     ch = new Channel();
     currentValue = "";
     currentFormula = "";
     InitializeComponent();
     InitializeBroadCastComboBox();
 }
Ejemplo n.º 6
0
        public void onRefreshButton(Office.IRibbonControl control)
        {
            Excel.Application exApp = Globals.ThisAddIn.Application as Excel.Application;
            Excel.Workbook wb = exApp.ActiveWorkbook as Excel.Workbook;
            Channel ch = new Channel();
            ch.setAuthToken(TokenStore.getTokenFromStore());

            string txt = ch.channelsRefresh(wb);
            MessageBox.Show(txt, "Refresh");
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Channel ch = new Channel();

            string token = ch.getToken("*****@*****.**", "password");
            ch.setAuthToken(token);

            string response = ch.getAllBroadcastsChannels().ToString();
            //string token = ch.getToken("*****@*****.**", "password");
            //Console.Write("Token from Website: " + token + "\n");

            //at.setToken(token);
            //at.createCookieInContainer();
            //string txt = at.readTokenFromCookie();
            //Console.Write("Cookie Token: " + txt + "\n");

            Console.Write(response);

            Console.Read();
        }
Ejemplo n.º 8
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            Channel ch = new Channel();

            string username = usernameBox.Text.ToString();
            string password = passwordBox.Text.ToString();
            string token = ch.getToken(username, password);

            if (token == "404"|token == "401")
            {
                loginErrorLabel.Visible = true;
            }
            else
            {
                loginErrorLabel.Visible = false;
                TokenStore.addTokenToStore(token);
                MessageBox.Show(TokenStore.getTokenFromStore(), "Token Obtained and Stored");

                LoginForm.ActiveForm.Close();

            }
        }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            Excel.Application exApp = Globals.ThisAddIn.Application as Excel.Application;
            Excel.Workbook wb = exApp.ActiveWorkbook as Excel.Workbook;
            Excel.Worksheet ws = exApp.ActiveSheet as Excel.Worksheet;
            Excel.Range rng = (Excel.Range)exApp.ActiveCell;

            Channel ch = new Channel();
            string returnID;
            string token;
            int broadcastID;

            string[] array = broadcastComboBox.SelectedItem.ToString().Split(new string[] { "-" }, StringSplitOptions.None);

            broadcastID = Convert.ToInt16(array[0]);

            //get token and send token together with publication request
            token = TokenStore.getTokenFromStore();
            ch.setAuthToken(token);
            returnID = ch.publishChannel(feedNametextBox.Text.ToString(), rng.Value.ToString(),
                spreadSheetID, broadcastID);
            rng.Name = "PUB_" + returnID;
            MessageBox.Show("Published as Channel ID:" + returnID, "Response from Server");

            //Add indicator to show publication status
            Excel.Shape aShape;
            aShape = ws.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeCross, rng.Left,
                                        rng.Top, 3, 3);
            aShape.Name = "Pub";
            aShape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
            aShape.Fill.Solid();
            aShape.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
            aShape.Fill.ForeColor.RGB = Color.FromArgb(200, 200, 90).ToArgb();
            aShape.Placement = Excel.XlPlacement.xlMove;

            PubForm.ActiveForm.Close();
        }
Ejemplo n.º 10
0
 private void updateChannelDescription(object sender, EventArgs e)
 {
     Channel ch = new Channel();
     this.readSelectedChannel();
     descriptionTextBox.Text = ch.getChannelDesc(channelSelected.ToString());
 }
Ejemplo n.º 11
0
        private void rePubButton_Click(object sender, EventArgs e)
        {
            string responseFromServer;

            Excel.Application exApp = Globals.ThisAddIn.Application as Excel.Application;
            Excel.Workbook wb = exApp.ActiveWorkbook as Excel.Workbook;
            Excel.Worksheet ws = exApp.ActiveSheet as Excel.Worksheet;
            Excel.Range rng = (Excel.Range)exApp.ActiveCell;
            Channel ch = new Channel();
            this.readSelectedChannel();
            ch.setAuthToken(TokenStore.getTokenFromStore());

            string to_replace = "";
            if (forceCheckBox.Checked)
            {
                to_replace = "true";
            }
            else
            {
                to_replace = "false";
            }

            responseFromServer = ch.rePublishChannel(channelSelected, descriptionTextBox.Text, rng.Value.ToString(),
                spreadSheetID, to_replace);
            MessageBox.Show(responseFromServer.ToString());
            if (responseFromServer == "409")
            {
                MessageBox.Show(@"This workbook is not the original publisher.
                        Please check 'OverWrite' and retry if you want to overwrite data in the channel", "Cannot Overwrite");
            }
            else if (responseFromServer == "401")
            {
                MessageBox.Show(@"You are not authorized to publish into the channel", "Unauthorized");
            }
            else
            {
                rng.Name = "PUB_" + channelSelected.ToString();

                //Add indicator to show publication status
                Excel.Shape aShape;
                aShape = ws.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeCross, rng.Left,
                                            rng.Top, 3, 3);
                aShape.Name = "Pub";
                aShape.Fill.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
                aShape.Fill.Solid();
                aShape.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
                aShape.Fill.ForeColor.RGB = Color.FromArgb(200, 200, 90).ToArgb();
                aShape.Placement = Excel.XlPlacement.xlMove;

                RePubForm.ActiveForm.Close();
            }
        }
Ejemplo n.º 12
0
        private void refreshAll(Office.CommandBarButton cmdBarbutton, ref bool cancel)
        {
            Excel.Application exApp = Globals.ThisAddIn.Application as Excel.Application;
            Excel.Workbook wb = exApp.ActiveWorkbook as Excel.Workbook;
            Channel ch = new Channel();
            string txt;

            txt = ch.channelsRefresh(wb);
            MessageBox.Show(txt, "Refresh");
        }
Ejemplo n.º 13
0
        public void onRegButton(Office.IRibbonControl control)
        {
            Excel.Application exApp = Globals.ThisAddIn.Application as Excel.Application;
            Excel.Workbook wb = exApp.ActiveWorkbook as Excel.Workbook ;
            string filename = wb.Name.ToString();

            Microsoft.Office.Core.DocumentProperties properties;
            properties = (Office.DocumentProperties)wb.CustomDocumentProperties;

            Channel ch = new Channel();
            ch.setAuthToken(TokenStore.getTokenFromStore());

            if (ch.checkSpreadSheetID(wb) == "0")
            {

                string fileID = ch.getSpreadSheetID(filename);
                MessageBox.Show(fileID, "File ID");

                properties.Add("Excalibur ID", false,
                    Microsoft.Office.Core.MsoDocProperties.msoPropertyTypeString, fileID);
            }
            else
            {
                MessageBox.Show("ID Exists - Excalibur ID: " + ch.checkSpreadSheetID(wb), "File Already Registered");
            }
        }