예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var context = HttpContext.Current;
        string reqheaders = "reached";
        var actualRequest = context.Request;
        var reqKeys = context.Request.Headers.AllKeys;
        string calId = string.Empty;
        bool isValid = false;
        GoogleService.IGoogleNotificationService client1 = new GoogleService.GoogleNotificationServiceClient();
        client1.CheckAllCalendarEvents(825);//.CheckCalendarEvents(calId);
        //ServiceReference1.IGoogleNotificationService client1 = new ServiceReference1.GoogleNotificationServiceClient();
        //client1.CheckCalendarEvents("*****@*****.**");
        var googlePushNotification = new GooglePushNotification();
        for (int i = 0; i < reqKeys.Count(); i++)
        {
            if (reqKeys[i] == "X-Goog-Resource-URI")
            {
                googlePushNotification.ResoourceURI = context.Request.Headers.Get(i).ToString();
                calId = context.Request.Headers.Get(i).Replace("https://www.googleapis.com/calendar/v3/calendars/", string.Empty);
                calId = calId.Replace("/events?alt=json", string.Empty);
                isValid = true;
            }
            else if (reqKeys[i] == "X-Goog-Channel-ID")
            {
                googlePushNotification.ChannelId = context.Request.Headers.Get(i).ToString();
            }
            else if (reqKeys[i] == "X-Goog-Channel-Expiration")
            {
                googlePushNotification.ChannelExpiration = DateTime.Parse(context.Request.Headers.Get(i).ToString().Replace("GMT",string.Empty).Trim());
            }
            else if (reqKeys[i] == "X-Goog-Resource-State")
            {
                googlePushNotification.ResourceState = context.Request.Headers.Get(i).ToString();
            }
            else if (reqKeys[i] == "X-Goog-Message-Number")
            {
                googlePushNotification.MessageNumber = long.Parse(context.Request.Headers.Get(i).ToString());
            }
            else if (reqKeys[i] == "X-Goog-Resource-ID")
            {
                googlePushNotification.ResourceId = context.Request.Headers.Get(i).ToString();
            }
            reqheaders = reqheaders + Environment.NewLine + reqKeys[i] + " : " + context.Request.Headers.Get(i);
        }

        //bool validChannel = false;
        //try
        //{
        //    if (activeChannels.Keys.Contains(googlePushNotification.ChannelId) || !activeChannels.Values.Contains(googlePushNotification.ResourceId))
        //    {
        //        validChannel = true;
        //    }
        //}
        //catch
        //{
        //}

        try
        {
            //if(validChannel)
            File.WriteAllText(@"C:\testDev.txt", reqheaders);
        }
        catch
        { }
        //isValid = true;
        //calId = "*****@*****.**";
        if (isValid)
        {
            try
            {
                if (isValid)
                {
                    GoogleService.IGoogleNotificationService client = new GoogleService.GoogleNotificationServiceClient();
                    client.CheckCalendarEvents(calId);
                    client.InsertGooglePushNotification(googlePushNotification.ChannelId, "", googlePushNotification.ChannelExpiration, googlePushNotification.ResourceId, googlePushNotification.ResoourceURI, googlePushNotification.ResourceState, googlePushNotification.MessageNumber);
                    //context.Response.StatusCode = 200;
                    //context.Response.End();
                    //return;
                }
            }
            catch (Exception ex)
            {
                File.WriteAllText(@"C:\Google.txt", ex.Message);
            }
        }
    }
예제 #2
0
 private void ProprtyCoordinates(int propertyId, string location)
 {
     try
     {
         GoogleService.IGoogleNotificationService google = new GoogleService.GoogleNotificationServiceClient();
         var coordinates = google.GetCoordinates(location);
         if (coordinates != null)
         {
             if (coordinates.Latitude != null && coordinates.Longitude != null)
             {
                 InsertPropertyCoordinates(propertyId, coordinates.Latitude, coordinates.Longitude);
             }
         }
     }
     catch
     { }
 }
예제 #3
0
        private bool InsertOrderIntoDatabase(Mail mail, CompanyMail companyMail, Order order, List<OrderItem> orderItems, int emailId, string fileName, string htmlText, List<SalesContact> salesContacts, List<AdminContact> adminContacts,string propertyAddress)
        {
            Email eml = new Email();
            bool status = false;
            int mailId = 0, CompanyMailId = 0, orderId = 0;
            SqlConnection db = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["DbConn"]);

            try
            {
                db.Open();

                mailId = InsertMail(mail, db);

                order.MailId = mailId;

                InsertComapnyMail(companyMail, db, mailId);

                orderId = InsertOrder(order, db);

                List<int> xeroIds = InsertOrderItems(orderItems, db, orderId);

                bool eventCreated = false;

                foreach (var xeroId in xeroIds)
                {
                    if (xeroId != null)
                    {
                        if (!eventCreated)
                        {
                            var dsProductNotification = ProductSchedule(xeroId);
                            if (dsProductNotification.Tables[0].Rows.Count > 0)
                            {
                                string productGroupName = string.Empty;
                                string productGroupId = string.Empty;
                                try
                                {
                                    if (dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["ProductGroupId"] != null)
                                    {
                                        productGroupId = dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["ProductGroupId"].ToString();
                                    }
                                    if (dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["ProductGroupName"] != null)
                                    {
                                        productGroupName = dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["ProductGroupName"].ToString();
                                    }
                                }
                                catch
                                {
                                    productGroupId = string.Empty;
                                    productGroupName = string.Empty;
                                }

                                if (dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["Value"].ToString().Contains("@"))
                                {
                                    eml.SendMail(mail.Subject, htmlText, "*****@*****.**", "", false);
                                    eventCreated = true;

                                }
                                else
                                {
                                    GoogleService.IGoogleNotificationService client = new GoogleService.GoogleNotificationServiceClient();
                                    string orderItemDetails = string.Empty;
                                    if (!string.IsNullOrEmpty(productGroupId))
                                    {
                                        orderItemDetails = "Order Item (Please do not delete or update Order Item Id) :" + order.OrderId + ", " + productGroupId + "-" + productGroupName;
                                    }
                                    else
                                    {
                                        orderItemDetails = "Order Item (Please do not delete or update Order Item Id) :" + order.OrderId;
                                    }
                                    string salesContactDetails = salesContacts.FirstOrDefault().SalesContactName + " on " + salesContacts.FirstOrDefault().SalesContactNumber1 + " or " + salesContacts.FirstOrDefault().SalesContactNumber2;
                                    //foreach (SalesContact salesContact in salesContacts)
                                    //{
                                    //    if (string.IsNullOrEmpty(salesContactDetails))
                                    //    {
                                    //        salesContactDetails = salesContact.SalesContactName + " on " + salesContact.SalesContactNumber1 + " or " + salesContact.SalesContactNumber2;
                                    //    }
                                    //    else
                                    //    {
                                    //        salesContactDetails = salesContactDetails + Environment.NewLine + salesContact.SalesContactName + " on " + salesContact.SalesContactNumber1 + " or " + salesContact.SalesContactNumber2;
                                    //    }
                                    //}

                                    string orderItemDescription = string.Empty;
                                    foreach (var item in orderItems)
                                    {
                                        if (string.IsNullOrEmpty(orderItemDescription))
                                        {
                                            orderItemDescription = item.Name;
                                        }
                                        else
                                        {
                                            orderItemDescription = orderItemDescription + Environment.NewLine + Environment.NewLine + item.Name;
                                        }
                                    }

                                    string description = "SalesContact : " + salesContactDetails + " " + Environment.NewLine + Environment.NewLine
                                                       + "Required On :" + Convert.ToDateTime(order.RequiredDate).ToShortDateString() + Environment.NewLine + Environment.NewLine
                                                       + "Product Description :" + orderItemDescription + Environment.NewLine + Environment.NewLine
                                        //+ "Supplier Instructions :" + dtRecordtoProcess.Rows[i]["Comments"].ToString().Replace("Supplier Instructions", "") + Environment.NewLine
                                                       + orderItemDetails;
                                    DateTime startDate = Convert.ToDateTime(mail.SentDate).AddHours(10);
                                    int intervalMinutes = int.Parse(dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["Value"].ToString());
                                    client.CreateEvent(dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["Title"].ToString(), propertyAddress + ",Australia", salesContactDetails, startDate, startDate.AddMinutes(intervalMinutes), order.Description, order.Description, order.OrderId, order.RequiredDate.ToString(), "8", "*****@*****.**", description, string.Empty, false);
                                    eventCreated = true;

                                }
                            }
                            UpdateOrderEvent(orderId);//Order Row_Id
                        }
                    }
                }

                status = true;
            }
            catch (SqlException sqlError)
            {
                RollbackOrder(mailId, CompanyMailId, orderId);
                string strLog = sqlError.StackTrace.ToString() + "~~~~~~~~~~~~Error~~~~~~~~~~~:" + sqlError.Message.ToString();
                eml.SendMail("Error in parsing file.. FileName : " + fileName + ".htm", "EmailInbox table Row_Id = " + emailId + Environment.NewLine + "Error :- " + strLog, "*****@*****.**", "", false);
                status = false;
            }
            if (db.State == ConnectionState.Open)
                db.Close();
            return status;
        }
예제 #4
0
        private bool InsertOrderIntoDatabase(Mail mail, CompanyMail companyMail, Order order, List<OrderItem> orderItems, int emailId, string fileName, string htmlText, List<SalesContact> salesContacts, List<AdminContact> adminContacts, string propertyAddress, DateTime sentDate)
        {
            string year = "", month = "", day = "";
            Email eml = new Email();
            bool status = false;
            int mailId = 0, CompanyMailId = 0, orderId = 0;
            int companyId = 0, userId = 0, calendarId = 0;
            string XeroCompanyName = string.Empty;
            int adminId = 0;
            int salesId = 0;
            SqlConnection db = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["DbConn"]);

            try
            {
                db.Open();

                mailId = InsertMail(mail, db);

                order.MailId = mailId;

                InsertComapnyMail(companyMail, db, mailId, order.PropertyId, propertyAddress);

                // insert sales contact
                foreach (var salesContact in salesContacts)
                {
                    InsertContact(companyMail.ComanyName, salesContact.SalesContactName, salesContact.SalesContactNumber1, "Sales", out salesId);
                }

                // insert admin contact
                foreach (var adminContact in adminContacts)
                {

                    InsertContact(companyMail.ComanyName, adminContact.Name, adminContact.Email, "Admin", out adminId);
                }

                orderId = InsertOrder(order, db);
                Dictionary<int, XeroProductInfo> xeroCodeCostDictionary = new Dictionary<int, XeroProductInfo>();
                List<int> xeroIds = InsertOrderItems(orderItems, db, orderId, out xeroCodeCostDictionary);

                GetCompanyIdPropertyIdUserIdCalendarId(companyMail.ComanyName, order.PropertyId, "*****@*****.**", out companyId, out propertyId, out userId, out calendarId, out createInvoice, out XeroCompanyName);//[email protected]

                if (propertyId != 0 && !string.IsNullOrEmpty(propertyAddress.Trim()))
                {
                    ProprtyCoordinates(propertyId, propertyAddress.Trim());
                }

                string companyCode = GetCompanyCode(companyMail.ComanyName);
                if (string.IsNullOrEmpty(companyCode))
                {
                    RollbackOrder(mailId, CompanyMailId, orderId);
                    string supportEmail = System.Configuration.ConfigurationSettings.AppSettings["supportEmail"];
                    string supportCCEmail = System.Configuration.ConfigurationSettings.AppSettings["supportCCEmail"];
                    string strLog = "~~~~~~~~~~~~No Company Match Found : Company Name : " + companyMail.ComanyName + "~~~~~~~~~~~:";
                    UpdateFailedOrder(emailId);
                    MoveRecievedFile(fileName, true, false);
                    eml.SendMail("No Company Match Found FileName : " + fileName + ".htm", "EmailInbox table Row_Id = " + emailId + Environment.NewLine + "Sentdate : " + sentDate + Environment.NewLine + "Error :- " + strLog, supportEmail, supportCCEmail, false);
                    status = false;
                    exceptionOccured = true;
                    return false;
                }

                bool eventCreated = false;

                if (!isCompanyMail && xeroIds.Count == 0)
                {
                    RollbackOrder(mailId, CompanyMailId, orderId);
                    string supportEmail = System.Configuration.ConfigurationSettings.AppSettings["supportEmail"];
                    string supportCCEmail = System.Configuration.ConfigurationSettings.AppSettings["supportCCEmail"];
                    string strLog = "~~~~~~~~~~~~No Product Match Found : Company Name : " + companyMail.ComanyName + "~~~~~~~~~~~:";
                    UpdateFailedOrder(emailId);
                    MoveRecievedFile(fileName, true, false);
                    eml.SendMail("No Product Match Found FileName : " + fileName + ".htm", "EmailInbox table Row_Id = " + emailId + Environment.NewLine + "Sentdate : " + sentDate + Environment.NewLine + "Error :- " + strLog, supportEmail, supportCCEmail, false);
                    status = false;
                    exceptionOccured = true;
                    return false;
                }
                if (!isCompanyMail)
                {
                    foreach (var xeroId in xeroIds)
                    {
                        if (xeroId != null)
                        {
                            //if (!eventCreated)
                            //{
                            var dsProductNotification = ProductSchedule(xeroId);
                            if (dsProductNotification.Tables[0].Rows.Count > 0)
                            {
                                foreach (DataRow row in dsProductNotification.Tables[0].Rows)
                                {
                                    string productGroupName = string.Empty;
                                    string productGroupId = string.Empty;
                                    try
                                    {
                                        if (row["ProductGroupId"] != null)
                                        {
                                            productGroupId = row["ProductGroupId"].ToString();
                                        }
                                        if (row["ProductGroupName"] != null)
                                        {
                                            productGroupName = row["ProductGroupName"].ToString();
                                        }
                                    }
                                    catch
                                    {
                                        productGroupId = string.Empty;
                                        productGroupName = string.Empty;
                                    }

                                    if (row["Value"].ToString().Contains("@"))
                                    {
                                        string dpiEmail = System.Configuration.ConfigurationSettings.AppSettings["dpiEmail"];
                                        string dpiCCEmail = System.Configuration.ConfigurationSettings.AppSettings["dpiCCEmail"];
                                        // need to comment below code while you debug this form local machine Manoj
                                        eml.SendMail(mail.Subject, htmlText, dpiEmail, dpiCCEmail, false);
                                        eventCreated = true;

                                    }
                                    else
                                    {
                                        GoogleService.IGoogleNotificationService client = new GoogleService.GoogleNotificationServiceClient();
                                        string orderItemDetails = string.Empty;
                                        if (!string.IsNullOrEmpty(productGroupId))
                                        {
                                            if (!string.IsNullOrEmpty(productGroupName))
                                            {
                                                orderItemDetails =
                                                    "Order Item (Please do not delete or update Order Item Id) :" +
                                                    order.OrderId + ", " + productGroupId + "-" + productGroupName;
                                            }
                                            else
                                            {
                                                orderItemDetails =
                                                    "Order Item (Please do not delete or update Order Item Id) :" +
                                                    order.OrderId + ", " + productGroupId;
                                            }
                                        }
                                        else
                                        {
                                            orderItemDetails = "Order Item (Please do not delete or update Order Item Id) :" + order.OrderId;
                                        }
                                        string salesContactDetails = salesContacts.FirstOrDefault().SalesContactName + " on " + salesContacts.FirstOrDefault().SalesContactNumber1 + " or " + salesContacts.FirstOrDefault().SalesContactNumber2;

                                        string orderItemDescription = string.Empty;
                                        foreach (var item in orderItems)
                                        {
                                            if (string.IsNullOrEmpty(orderItemDescription))
                                            {
                                                orderItemDescription = item.Name;
                                            }
                                            else
                                            {
                                                orderItemDescription = orderItemDescription + Environment.NewLine + Environment.NewLine + item.Name;
                                            }
                                        }

                                        string description = "SalesContact : " + salesContactDetails + " " + Environment.NewLine + Environment.NewLine
                                                             + "Required On :" + Convert.ToDateTime(order.RequiredDate).ToShortDateString() + Environment.NewLine + Environment.NewLine
                                                             + "Product Description :" + orderItemDescription + Environment.NewLine + Environment.NewLine
                                            //+ "Supplier Instructions :" + dtRecordtoProcess.Rows[i]["Comments"].ToString().Replace("Supplier Instructions", "") + Environment.NewLine
                                                             + orderItemDetails;

                                        string title = companyCode + ":" + propertyAddress + ":" + row["Title"].ToString() ?? order.Description;
                                        string colorId = row["ColorId"].ToString();

                                        //GetStartDate(mail.SentDate, out year, out month, out day);
                                        var startDate = sentDate;// GetStartDate(mail.SentDate);

                                        //DateTime startDate = Convert.ToDateTime(mail.SentDate);

                                        if (startDate.TimeOfDay.Minutes < 15 && startDate.TimeOfDay.Minutes > 0)
                                        {
                                            startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startDate.Hour, 00, 00);
                                        }
                                        else if (startDate.TimeOfDay.Minutes < 30 && startDate.TimeOfDay.Minutes > 15)
                                        {
                                            startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startDate.Hour, 30, 00);
                                        }

                                        else if (startDate.TimeOfDay.Minutes < 45 && startDate.TimeOfDay.Minutes > 30)
                                        {
                                            startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startDate.Hour, 30, 00);
                                        }
                                        else if (startDate.TimeOfDay.Minutes < 45)
                                        {
                                            startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startDate.Hour + 1, 00, 00);
                                        }
                                        int intervalMinutes = int.Parse(row["Value"].ToString());

                                        // need to change [email protected] into [email protected] below code while you debug this form local machine
                                        var returnEventId = client.CreateEvent(title, propertyAddress + ",Australia", salesContactDetails, startDate, startDate.AddMinutes(intervalMinutes), order.Description, order.Description, order.OrderId, order.RequiredDate.ToString(), colorId, "*****@*****.**", description, string.Empty, false);
                                        // var returnEventId = client.CreateEvent(title, propertyAddress + ",Australia", salesContactDetails, startDate, startDate.AddMinutes(intervalMinutes), order.Description, order.Description, order.OrderId, order.RequiredDate.ToString(), colorId, "*****@*****.**", description, string.Empty, false);
                                        if (!string.IsNullOrEmpty(returnEventId))
                                        {
                                            eventCreated = true;
                                            int eventId = GetEventId(returnEventId.Split(',')[0]);
                                            int jobId = CreateJob(825, orderId, userId, propertyId, order.RequiredDate, mailId, companyId, "Not Cancelled", "", adminId);
                                            CreateEvent(825, jobId, userId, calendarId, eventId, int.Parse(productGroupId), "Not Cancelled", "");
                                        }
                                        else
                                        {
                                            throw new Exception("Google service has problem");
                                        }
                                    }
                                    UpdateOrderEvent(orderId);//Order Row_Id
                                }
                                //string productGroupName = string.Empty;
                                //string productGroupId = string.Empty;
                                //try
                                //{
                                //    if (dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["ProductGroupId"] != null)
                                //    {
                                //        productGroupId = dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["ProductGroupId"].ToString();
                                //    }
                                //    if (dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["ProductGroupName"] != null)
                                //    {
                                //        productGroupName = dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["ProductGroupName"].ToString();
                                //    }
                                //}
                                //catch
                                //{
                                //    productGroupId = string.Empty;
                                //    productGroupName = string.Empty;
                                //}

                                //if (dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["Value"].ToString().Contains("@"))
                                //{
                                //    string dpiEmail = System.Configuration.ConfigurationSettings.AppSettings["dpiEmail"];
                                //    string dpiCCEmail = System.Configuration.ConfigurationSettings.AppSettings["dpiCCEmail"];
                                //    //eml.SendMail(mail.Subject, htmlText, dpiEmail, dpiCCEmail, false);
                                //    eventCreated = true;

                                //}
                                //else
                                //{
                                //    GoogleService.IGoogleNotificationService client = new GoogleService.GoogleNotificationServiceClient();
                                //    string orderItemDetails = string.Empty;
                                //    if (!string.IsNullOrEmpty(productGroupId))
                                //    {
                                //        orderItemDetails = "Order Item (Please do not delete or update Order Item Id) :" + order.OrderId + ", " + productGroupId + "-" + productGroupName;
                                //    }
                                //    else
                                //    {
                                //        orderItemDetails = "Order Item (Please do not delete or update Order Item Id) :" + order.OrderId;
                                //    }
                                //    string salesContactDetails = salesContacts.FirstOrDefault().SalesContactName + " on " + salesContacts.FirstOrDefault().SalesContactNumber1 + " or " + salesContacts.FirstOrDefault().SalesContactNumber2;

                                //    string orderItemDescription = string.Empty;
                                //    foreach (var item in orderItems)
                                //    {
                                //        if (string.IsNullOrEmpty(orderItemDescription))
                                //        {
                                //            orderItemDescription = item.Name;
                                //        }
                                //        else
                                //        {
                                //            orderItemDescription = orderItemDescription + Environment.NewLine + Environment.NewLine + item.Name;
                                //        }
                                //    }

                                //    string description = "SalesContact : " + salesContactDetails + " " + Environment.NewLine + Environment.NewLine
                                //                       + "Required On :" + Convert.ToDateTime(order.RequiredDate).ToShortDateString() + Environment.NewLine + Environment.NewLine
                                //                       + "Product Description :" + orderItemDescription + Environment.NewLine + Environment.NewLine
                                //        //+ "Supplier Instructions :" + dtRecordtoProcess.Rows[i]["Comments"].ToString().Replace("Supplier Instructions", "") + Environment.NewLine
                                //                       + orderItemDetails;
                                //    string companyCode = GetCompanyCode(companyMail.ComanyName);

                                //    string title = companyCode + ":" + propertyAddress + ":" + dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["Title"].ToString() ?? order.Description;
                                //    string colorId = dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["ColorId"].ToString();

                                //    //GetStartDate(mail.SentDate, out year, out month, out day);
                                //    var startDate = sentDate;// GetStartDate(mail.SentDate);

                                //    //DateTime startDate = Convert.ToDateTime(mail.SentDate);

                                //    if (startDate.TimeOfDay.Minutes < 15 && startDate.TimeOfDay.Minutes > 0)
                                //    {
                                //        startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startDate.Hour, 00, 00);
                                //    }
                                //    else if (startDate.TimeOfDay.Minutes < 30 && startDate.TimeOfDay.Minutes > 15)
                                //    {
                                //        startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startDate.Hour, 30, 00);
                                //    }

                                //    else if (startDate.TimeOfDay.Minutes < 45 && startDate.TimeOfDay.Minutes > 30)
                                //    {
                                //        startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startDate.Hour, 30, 00);
                                //    }
                                //    else if (startDate.TimeOfDay.Minutes < 45)
                                //    {
                                //        startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, startDate.Hour + 1, 00, 00);
                                //    }
                                //    int intervalMinutes = int.Parse(dsProductNotification.Tables[0].Rows[dsProductNotification.Tables[0].Rows.Count - 1]["Value"].ToString());
                                //    //var returnEventId = client.CreateEvent(title, propertyAddress + ",Australia", salesContactDetails, startDate, startDate.AddMinutes(intervalMinutes), order.Description, order.Description, order.OrderId, order.RequiredDate.ToString(), colorId, "*****@*****.**", description, string.Empty, false);
                                //    //if (!string.IsNullOrEmpty(returnEventId))
                                //    //{
                                //    //    eventCreated = true;
                                //    //    int eventId = GetEventId(returnEventId.Split(',')[0]);
                                //    //    int jobId = CreateJob(825, orderId, userId, propertyId, order.RequiredDate, mailId, companyId, "Not Cancelled", "");
                                //    //    CreateEvent(825, jobId, userId, calendarId, eventId, int.Parse(productGroupId), "Not Cancelled", "");
                                //    //}
                                //    //else
                                //    //{
                                //    //    throw new Exception("Google service has problem");
                                //    //}
                                //}
                                //UpdateOrderEvent(orderId);//Order Row_Id
                            }

                            //}
                        }
                    }
                }
                AddItemsToXeroInvoice(propertyAddress, xeroIds, XeroCompanyName, xeroCodeCostDictionary);
                status = true;
            }
            catch (Exception sqlError)
            {
                RollbackOrder(mailId, CompanyMailId, orderId);
                string supportEmail = System.Configuration.ConfigurationSettings.AppSettings["supportEmail"];
                string supportCCEmail = System.Configuration.ConfigurationSettings.AppSettings["supportCCEmail"];
                string strLog = sqlError.StackTrace.ToString() + "~~~~~~~~~~~~Error~~~~~~~~~~~:" + sqlError.Message.ToString();
                UpdateFailedOrder(emailId);
                MoveRecievedFile(fileName, true, false);
                eml.SendMail("Error in parsing file.. FileName : " + fileName + ".htm", "EmailInbox table Row_Id = " + emailId + Environment.NewLine + "Sentdate : " + sentDate + Environment.NewLine + "Error :- " + strLog, supportEmail, supportCCEmail, false);
                status = false;
                exceptionOccured = true;
            }
            if (db.State == ConnectionState.Open)
                db.Close();
            return status;
        }