public void SaveAttachments()
        {
            OutlookController controller = new OutlookController();
            ViewResult        result     = controller.SaveAttachments() as ViewResult;

            Assert.IsNotNull(result);
        }
        public void SaveAttachmentToServer()
        {
            var requestParams = new NameValueCollection
            {
                { "FileName", TestData.fileName },
                { "Docid", TestData.folderId },
                { "Ondup", "2" },
                { "TokenId", TestData.access_token },
                { "AttachmentId", "AttachmentId" },
                { "EwsUrl", "EwsUrl" },
                { "EwsId", "EwsId" },
                { "EwsToken", "EwsToken" }
            };

            var context = new Mock <ControllerContext>();

            context.SetupGet(x => x.HttpContext.Request.Form).Returns(requestParams);

            var controller = new OutlookController()
            {
                ControllerContext = context.Object
            };
            JsonResult result = controller.SaveAttachmentToServer();

            Assert.IsNotNull(result.Data);
        }
        public void AddAttachments()
        {
            OutlookController controller = new OutlookController();
            ViewResult        result     = controller.AddAttachments() as ViewResult;

            Assert.IsNotNull(result.ViewBag.ASUrl);
        }
        public void UpdateShareLink()
        {
            var requestParams = new NameValueCollection
            {
                { "TokenId", TestData.access_token },
                { "LinkId", linkId },
                { "Perm", "7" },
                { "ExpiresAt", "2020-09-30T08:00:00+08:00" },
                { "LimitedTimes", "10" },
                { "Password", "Password" },
                { "Title", "Title" }
            };

            var context = new Mock <ControllerContext>();

            context.SetupGet(x => x.HttpContext.Request.Form).Returns(requestParams);

            var controller = new OutlookController()
            {
                ControllerContext = context.Object
            };
            JsonResult result = controller.UpdateShareLink();

            Assert.IsNotNull(result.Data);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            IAttach           attach            = new AttachController();
            OutlookController outlookController = new OutlookController(attach);

            outlookController.Read();
            throw new Exception("");
            //
            IGmail gmail = new GmailController(attach);

            UserCredential credential;

            using (var stream = new FileStream(@pathinit + @"\client_secret.json", FileMode.Open, FileAccess.Read))
            {
                try
                {
                    //  string credPath = System.Environment.GetFolderPath(
                    //System.Environment.SpecialFolder.Personal);
                    string credPath = pathinit;
                    credPath = Path.Combine(credPath, ".credentials/gmail-dotnet-quickstart.json");

                    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                        GoogleClientSecrets.Load(stream).Secrets,
                        Scopes,
                        "user",
                        CancellationToken.None,
                        new FileDataStore(credPath, true)).Result;
                    Console.WriteLine("Credential file saved to: " + credPath);
                }
                catch (Exception ex)
                {
                    Console.Write(ex);
                    throw;
                }
            }

            // Create Gmail API service.
            var service = new GmailService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            // Define parameters of request.
            UsersResource.LabelsResource.ListRequest request = service.Users.Labels.List("me");
            // start read mail
            //UsersResource.MessagesResource.ListRequest requestMessage = service.Users.Messages.List("me");
            //IList<Message> listMessage = requestMessage.Execute().Messages;

            IList <Message> listMessage = gmail.ListMessages(service, "me", "has:attachment");

            foreach (var item in listMessage)
            {
                var res = gmail.GetMessage(service, "me", item.Id);
                gmail.GetAttachments(service, "me", res.Id);
            }

            Console.Read();
        }
        public void Index()
        {
            OutlookController controller = new OutlookController();
            ViewResult        result     = controller.Index() as ViewResult;

            Assert.IsNotNull(result.ViewBag.HelpUrl);
            Assert.IsNotNull(result.ViewBag.VersionInfo);
            Assert.IsNotNull(result.ViewBag.PublishDate);
        }
Exemplo n.º 7
0
        public void             Test_Reset(string connectionString)
        {
            sqlController = new SqlController(connectionString);
            Log log = sqlController.StartLog(this);

            outlookController = new OutlookController(sqlController, log);
            AdminTools at = new AdminTools(sqlController.SettingRead(Settings.microtingDb));

            try
            {
                if (!coreRunning && !coreStatChanging)
                {
                    coreStatChanging = true;
                    log.LogStandard("Not Specified", "Reset!");

                    List <Appointment> lstAppointments;

                    DateTime now          = DateTime.Now;
                    DateTime rollBackTo__ = now.AddDays(+2);
                    DateTime rollBackFrom = now.AddDays(-3);

                    lstAppointments = outlookController.UnitTest_CalendarItemGetAllNonRecurring(rollBackFrom, rollBackTo__);
                    foreach (var item in lstAppointments)
                    {
                        outlookController.CalendarItemUpdate(item, WorkflowState.Planned, true);
                    }

                    sqlController.SettingUpdate(Settings.checkLast_At, now.ToString());

                    at.RetractEforms();

                    sqlController.UnitTest_TruncateTable_Outlook("appointment_versions");
                    sqlController.UnitTest_TruncateTable_Outlook("appointments");
                    sqlController.UnitTest_TruncateTable_Microting("a_interaction_case_lists");
                    sqlController.UnitTest_TruncateTable_Microting("a_interaction_cases");
                    sqlController.UnitTest_TruncateTable_Microting("notifications");
                    sqlController.UnitTest_TruncateTable_Microting("cases");

                    coreStatChanging = false;
                }
            }
            catch (Exception ex)
            {
                FatalExpection(t.GetMethodName() + "failed. Core failed to restart", ex);
            }
            Close();
        }
        public void SaveEmailToServer()
        {
            SaveEmailModel saveEmailModel = new SaveEmailModel()
            {
                Docid    = TestData.folderId,
                EwsId    = "EwsId",
                EwsToken = "EwsToken",
                EwsUrl   = "EwsUrl",
                FileName = TestData.fileName,
                Ondup    = 2,
                TokenId  = TestData.access_token
            };
            OutlookController controller = new OutlookController();
            JsonResult        result     = controller.SaveEmailToServer(saveEmailModel);

            Assert.IsNotNull(result.Data);
        }
Exemplo n.º 9
0
        public bool             Close()
        {
            try
            {
                if (coreRunning && !coreStatChanging)
                {
                    coreStatChanging = true;

                    coreThreadAlive = false;
                    log.LogCritical("Not Specified", "Core.Close() at:" + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString());


                    while (coreRunning)
                    {
                        Thread.Sleep(200);
                    }

                    while (syncOutlookAppsRunning)
                    {
                        Thread.Sleep(200);
                    }

                    while (syncInteractionCaseRunning)
                    {
                        Thread.Sleep(200);
                    }

                    log.LogStandard("Not Specified", "Core closed");

                    outlookController = null;
                    sqlController     = null;

                    coreStatChanging = false;
                }
            }
            catch (ThreadAbortException)
            {
                //"Even if you handle it, it will be automatically re-thrown by the CLR at the end of the try/catch/finally."
                Thread.ResetAbort(); //This ends the re-throwning
            }
            catch (Exception ex)
            {
                FatalExpection(t.GetMethodName() + "failed. Core failed to close", ex);
            }
            return(true);
        }
        public void GetShareLinkSwitch()
        {
            var requestParams = new NameValueCollection
            {
                { "TokenId", TestData.access_token }
            };

            var context = new Mock <ControllerContext>();

            context.SetupGet(x => x.HttpContext.Request.Form).Returns(requestParams);

            var controller = new OutlookController()
            {
                ControllerContext = context.Object
            };
            JsonResult result = controller.GetShareLinkSwitch();

            Assert.IsNotNull(result.Data);
        }
Exemplo n.º 11
0
        //con

        #region public state
        public bool             Start(string connectionString)
        {
            try
            {
                if (!coreRunning && !coreStatChanging)
                {
                    coreStatChanging = true;

                    if (string.IsNullOrEmpty(connectionString))
                    {
                        throw new ArgumentException("serverConnectionString is not allowed to be null or empty");
                    }

                    //sqlController
                    sqlController = new SqlController(connectionString);

                    //check settings
                    if (sqlController.SettingCheckAll().Count > 0)
                    {
                        throw new ArgumentException("Use AdminTool to setup database correctly. 'SettingCheckAll()' returned with errors");
                    }

                    if (sqlController.SettingRead(Settings.microtingDb) == "...missing...")
                    {
                        throw new ArgumentException("Use AdminTool to setup database correctly. microtingDb(connection string) not set, only default value found");
                    }

                    if (sqlController.SettingRead(Settings.firstRunDone) != "true")
                    {
                        throw new ArgumentException("Use AdminTool to setup database correctly. FirstRunDone has not completed");
                    }

                    //log
                    log = sqlController.StartLog(this);

                    log.LogCritical("Not Specified", "###########################################################################");
                    log.LogCritical("Not Specified", t.GetMethodName() + " called");
                    log.LogStandard("Not Specified", "SqlController and Logger started");

                    //settings read
                    this.connectionString = connectionString;
                    log.LogStandard("Not Specified", "Settings read");

                    //outlookController
                    outlookController = new OutlookController(sqlController, log);
                    log.LogStandard("Not Specified", "OutlookController started");

                    //coreThread
                    Thread coreThread = new Thread(() => CoreThread());
                    coreThread.Start();
                    log.LogStandard("Not Specified", "CoreThread started");

                    log.LogStandard("Not Specified", "Core started");
                    coreRunning      = true;
                    coreStatChanging = false;
                }
            }
            #region catch
            catch (Exception ex)
            {
                coreRunning      = false;
                coreStatChanging = false;

                FatalExpection(t.GetMethodName() + " failed", ex);
                return(false);
            }
            #endregion

            return(true);
        }