Exemplo n.º 1
0
        public ActionResult NewTrialAccount(String username, String password, int planID)
        {
            SSMEntities  se    = new SSMEntities();
            TrialAccount trail = new TrialAccount();

            trail.UserName = username;
            trail.Password = password;
            trail.PlanID   = planID;
            trail.Status   = 1;
            se.TrialAccounts.Add(trail);
            se.SaveChanges();
            return(RedirectToAction("MarketPlanDetail", new { id = planID }));
        }
Exemplo n.º 2
0
        public ActionResult PlanTrialImport(HttpPostedFileBase excelfile, int planID)
        {
            SSMEntities se = new SSMEntities();

            if (excelfile == null || excelfile.ContentLength == 0)
            {
                ViewBag.Error = "Please select an Excel file<br>";
                return(View("Index"));
            }
            else
            {
                if (excelfile.FileName.EndsWith("xls") || excelfile.FileName.EndsWith("xlsx"))
                {
                    string path = Server.MapPath("~/Content/" + excelfile.FileName);
                    System.Diagnostics.Debug.WriteLine("noa ne: " + path);
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    excelfile.SaveAs(path);
                    // Read data from excel file
                    Excel.Application   application  = new Excel.Application();
                    Excel.Workbook      workbook     = application.Workbooks.Open(path);
                    Excel.Worksheet     worksheet    = workbook.ActiveSheet;
                    Excel.Range         range        = worksheet.UsedRange;
                    List <TrialAccount> listAccounts = new List <TrialAccount>();
                    // row = 3 is the row data begin with - 1
                    for (int row = 3; row <= range.Rows.Count; row++)
                    {
                        TrialAccount account = new TrialAccount();
                        account.UserName = ((Excel.Range)range.Cells[row, 1]).Text;
                        account.Password = ((Excel.Range)range.Cells[row, 2]).Text;
                        account.PlanID   = planID;
                        account.Status   = 1;

                        //account.PlanID = int.Parse(((Excel.Range)range.Cells[row, 3]).Text);
                        //DateTime createdDate = Convert.ToDateTime(((Excel.Range)range.Cells[row, 4]).Text);
                        //account.createdDate = createdDate;
                        se.TrialAccounts.Add(account);
                    }
                    application.Workbooks.Close();
                    se.SaveChanges();

                    return(RedirectToAction("MarketPlanDetail", new { id = planID }));
                }
                else
                {
                    return(RedirectToAction("MarketPlanDetail", new { id = planID }));
                }
            }
        }
Exemplo n.º 3
0
        public int createAndGetDealID(Deal deal, int productID, int plann)
        {
            SSMEntities     se      = new SSMEntities();
            softwareProduct product = se.softwareProducts.Find(productID);

            if (product != null)
            {
                deal.ProductID = productID;
            }
            deal.Creator         = User.Identity.GetUserId();
            deal.StartDate       = DateTime.Today;
            deal.Stage           = 1;
            deal.Probability     = 0;
            deal.CompleteOn      = null;
            deal.LastUpdateStage = null;
            deal.Status          = 1;
            deal.CurrentPlanID   = product.PrePurchase_FollowUp_Plan.Where(u => u.isOperation).FirstOrDefault().id;

            se.Deals.Add(deal);
            se.SaveChanges();
            Deal_Item         ite = new Deal_Item();
            productMarketPlan pla = se.productMarketPlans.Find(plann);

            ite.planID   = plann;
            ite.price    = pla.ceilPrice;
            ite.Quantity = 1;
            ite.dealID   = deal.id;
            se.Deal_Item.Add(ite);
            deal.Value = ite.price;
            se.SaveChanges();
            Deal_SaleRep_Respon dealrespont = new Deal_SaleRep_Respon();

            dealrespont.dealID = deal.id;
            dealrespont.userID = deal.Creator;
            se.Deal_SaleRep_Respon.Add(dealrespont);
            se.SaveChanges();
            contact contact = se.contacts.Find(deal.Client);
            int     day     = 0;
            PrePurchase_FollowUp_Plan plan = deal.softwareProduct.PrePurchase_FollowUp_Plan.Where(u => u.isOperation == true).FirstOrDefault();

            if (contact != null)
            {
                foreach (Plan_Step tep in plan.Plan_Step)
                {
                    if (tep.TimeFromLastStep == null)
                    {
                        tep.TimeFromLastStep = 0;
                    }
                    day = day + (int)tep.TimeFromLastStep;
                    DealTask task = new DealTask();
                    task.dealID          = deal.id;
                    task.TaskDescription = tep.StepEmailContent;
                    task.status          = 1;
                    if (tep.RequireMoreDetail)
                    {
                        task.status = 7;
                    }
                    task.Deadline    = DateTime.Now.AddDays(day);
                    task.CreateDate  = DateTime.Now;
                    task.TaskContent = tep.stepNo + "";
                    task.TaskName    = tep.subject + " [#:" + deal.id + "]";
                    task.type        = 8;
                    se.DealTasks.Add(task);
                    se.SaveChanges();
                    if (task.TaskDescription.Contains(se.ConfigureSys.Find(13).value))
                    {
                        String replaceall = "";
                        foreach (Deal_Item item in task.Deal.Deal_Item)
                        {
                            TrialAccount trial = item.productMarketPlan.TrialAccounts.Where(u => u.contactID == null).FirstOrDefault();
                            replaceall = replaceall + '\n' + "User Name for " + item.productMarketPlan.Name + ": " + trial.UserName + " Password: " + trial.Password;
                            TrialAccount trialupdate = se.TrialAccounts.Find(trial.AccountID);
                            trialupdate.contactID = task.Deal.contact.id;
                            se.SaveChanges();
                        }
                        task.TaskDescription = task.TaskDescription.Replace(se.ConfigureSys.Find(13).value, replaceall);
                    }
                    se.SaveChanges();
                }
            }


            return(deal.id);
        }