Exemplo n.º 1
0
        private void movement(DTOstockmovement r)
        {
            var userID = KOCAuthorizeAttribute.getCurrentUser().userId;

            using (var db = new KOCSAMADLSEntities())
            {
                adsl_stockmovement sm = new adsl_stockmovement();
                sm.serialno       = r.serialno;
                sm.lastupdated    = DateTime.Now;
                sm.updatedby      = userID;
                sm.creationdate   = DateTime.Now;
                sm.toobjecttype   = r.toobjecttype;
                sm.stockcardid    = r.stockcardid;
                sm.toobject       = r.toobject;
                sm.deleted        = false;
                sm.amount         = r.amount;
                sm.fromobjecttype = r.fromobjecttype;
                sm.fromobject     = r.fromobject;
                sm.movementdate   = DateTime.Now;
                if (r.fromobjecttype == 16777217 || r.toobjecttype == 16777217 || r.fromobjecttype == 33554433)
                {
                    sm.confirmationdate = DateTime.Now;                                                                                             // hareket müşteridense onaylı olmalı
                }
                sm.updatedby = userID;
                db.stockmovement.Add(sm);
                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage savePersonel(DTOpersonel request)
        {
            using (var db = new KOCSAMADLSEntities())
            {
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                var dp = db.personel.Where(t => t.personelid == request.personelid).FirstOrDefault();

                dp.personelname      = request.personelname;
                dp.category          = (int)request.category;
                dp.roles             = dp.category = (int)request.category;
                dp.relatedpersonelid = request.relatedpersonelid;
                dp.kurulumpersonelid = request.kurulumpersonelid;
                dp.ilceKimlikNo      = request.ilceKimlikNo;
                dp.ilKimlikNo        = request.ilKimlikNo;
                dp.mobile            = request.mobile;
                dp.email             = request.email;
                dp.password          = request.password;
                dp.notes             = request.notes;
                dp.responseregions   = request.responseregions;
                dp.lastupdated       = DateTime.Now;
                dp.updatedby         = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId;
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Exemplo n.º 3
0
 public HttpResponseMessage updatePersonelAtama(DTOatama request)
 {
     using (var db = new KOCSAMADLSEntities())
         using (var tran = db.Database.BeginTransaction())
             try
             {
                 var upa = db.atama.Where(r => r.id == request.id).FirstOrDefault();
                 upa.closedtasktype    = request.closedtasktype;
                 upa.closedtask        = request.closedtask;
                 upa.offpersonel       = request.offpersonel;
                 upa.formedtasktype    = request.formedtasktype;
                 upa.formedtask        = request.formedtask;
                 upa.appointedpersonel = request.appointedpersonel;
                 db.SaveChanges();
                 tran.Commit();
                 var errormessage = new DTOResponseError {
                     errorCode = 1, errorMessage = "Atama Düzenleme Tamamlandı."
                 };
                 return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
             }
             catch (Exception)
             {
                 tran.Rollback();
                 var errormessage = new DTOResponseError {
                     errorCode = 2, errorMessage = "Atama Düzenleme Tamamlanamadı!"
                 };
                 return(Request.CreateResponse(HttpStatusCode.NotModified, errormessage, "application/json"));
             }
 }
Exemplo n.º 4
0
 public HttpResponseMessage insertPersonel(DTOpersonel request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         var p = new adsl_personel
         {
             personelname      = request.personelname,
             category          = (int)request.category,
             mobile            = request.mobile,
             email             = request.email,
             password          = request.password,
             notes             = request.notes,
             roles             = (int)request.category,
             relatedpersonelid = request.relatedpersonelid != 0 ? request.relatedpersonelid : null,
             kurulumpersonelid = request.kurulumpersonelid,
             ilceKimlikNo      = request.ilceKimlikNo,
             ilKimlikNo        = request.ilKimlikNo,
             creationdate      = DateTime.Now,
             lastupdated       = DateTime.Now,
             deleted           = false,
             updatedby         = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId
         };
         db.personel.Add(p);
         db.SaveChanges();
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Exemplo n.º 5
0
 public HttpResponseMessage insertTaskState(DTOtaskstatematches request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var tsm = new adsl_taskstatematches
         {
             taskid             = request.task.taskid,
             stateid            = request.taskstatepool.taskstateid,
             automandatorytasks = request.automandatorytasks,
             autooptionaltasks  = request.autooptionaltasks,
             stockcards         = request.stockcards,
             documents          = request.documents,
             creationdate       = DateTime.Now,
             lastupdated        = DateTime.Now,
             updatedby          = KOCAuthorizeAttribute.getCurrentUser().userId,
             deleted            = false
         };
         db.taskstatematches.Add(tsm);
         db.SaveChanges();
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Exemplo n.º 6
0
        public HttpResponseMessage updateSL(DTOSL request)
        { // SL hesaplamaları için gerekli olan bilgilerin güncellenmesi (Hüseyin KOZ)
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new KOCSAMADLSEntities())
                using (var tran = db.Database.BeginTransaction())
                    try
                    {
                        var upa = db.SL.Where(r => r.SLID == request.SLID).FirstOrDefault();
                        upa.SLName      = request.SLName;
                        upa.KocSTask    = request.KocSTask;
                        upa.KocETask    = request.KocETask;
                        upa.KocMaxTime  = request.KocMaxTime;
                        upa.BayiSTask   = request.BayiSTask;
                        upa.BayiETask   = request.BayiETask;
                        upa.BayiMaxTime = request.BayiMaxTime;
                        upa.lastupdated = DateTime.Now;
                        upa.updatedby   = user.userId;
                        db.SaveChanges();
                        tran.Commit();
                        var errormessage = new DTOResponseError {
                            errorCode = 1, errorMessage = "SL Düzenleme Tamamlandı."
                        };
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        var errormessage = new DTOResponseError {
                            errorCode = 2, errorMessage = "SL Düzenleme Tamamlanamadı!"
                        };
                        return(Request.CreateResponse(HttpStatusCode.NotModified, errormessage, "application/json"));
                    }
        }
Exemplo n.º 7
0
 public HttpResponseMessage insertTask(DTOtask request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var errormessage = new DTOResponseError();
         var t            = new adsl_task
         {
             taskname               = request.taskname,
             attachableobjecttype   = request.objecttypes.typeid,
             attachablepersoneltype = request.personeltypes.typeid,
             performancescore       = request.performancescore,
             tasktype               = request.tasktypes.TaskTypeId,
             deleted      = false,
             creationdate = DateTime.Now,
             lastupdated  = DateTime.Now,
             updatedby    = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId,
             description  = request.description,
         };
         db.task.Add(t);
         db.SaveChanges();
         errormessage.errorCode    = 1;
         errormessage.errorMessage = "İşlem Başarılı";
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Exemplo n.º 8
0
        public HttpResponseMessage deleteSL(int SLID)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new KOCSAMADLSEntities())
                using (var tran = db.Database.BeginTransaction())
                    try
                    {
                        var upa = db.SL.Where(r => r.SLID == SLID).FirstOrDefault();
                        //upa.deleted = true; //delete işlemi sayfadan yapılacaksa aktif edilip işlem burdan sağlanacak (Hüseyin KOZ)
                        upa.lastupdated = DateTime.Now;
                        upa.updatedby   = user.userId;
                        db.SaveChanges();
                        tran.Commit();
                        var errormessage = new DTOResponseError {
                            errorCode = 1, errorMessage = "işlem Gerçekleştirildi."
                        };
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        var errormessage = new DTOResponseError {
                            errorCode = 2, errorMessage = "işlem Tamamlanamadı!"
                        };
                        return(Request.CreateResponse(HttpStatusCode.NotModified, errormessage, "application/json"));
                    }
        }
Exemplo n.º 9
0
        public HttpResponseMessage confirmSM(int[] movementIds)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();
            DTOResponseError errormessage = new DTOResponseError();

            if (movementIds.Length > 0)
            {
                using (var db = new KOCSAMADLSEntities())
                    using (var tran = db.Database.BeginTransaction())
                        try
                        {
                            //yalnızca kendine çıkılan stoklar onaylanabilir
                            if (db.stockmovement.Where(s => movementIds.Contains(s.movementid)).Any(a => a.toobject == user.userId))
                            {
                                foreach (var item in movementIds)
                                {
                                    var sm = db.stockmovement.Where(s => s.movementid == item && s.confirmationdate == null).FirstOrDefault();
                                    sm.confirmationdate = DateTime.Now;
                                    sm.updatedby        = user.userId;
                                    sm.lastupdated      = DateTime.Now;
                                }
                                db.SaveChanges();
                                tran.Commit();
                                errormessage.errorMessage = "Onaylama işlemi başarılı";
                                errormessage.errorCode    = 1;
                                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                            }
                            else
                            {
                                errormessage.errorMessage = "Sadece Üzerinize Atanmış Stokları Onaylayabilirsiniz";
                                errormessage.errorCode    = -1;
                                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                            }
                        }
                        catch (Exception)
                        {
                            tran.Rollback();
                            errormessage = new DTOResponseError {
                                errorCode = 2, errorMessage = "işlem Tamamlanamadı!"
                            };
                            return(Request.CreateResponse(HttpStatusCode.NotModified, errormessage, "application/json"));
                        }
            }
            else
            {
                errormessage.errorMessage = "Onaylamak İçin En Az 1 Stok Hareketi Seçmelisiniz!";
                errormessage.errorCode    = -1;
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Exemplo n.º 10
0
        public HttpResponseMessage saveDocument(DTOdocument request)
        {
            using (var db = new KOCSAMADLSEntities())
            {
                var ddoc = db.document.Where(d => d.documentid == request.documentid).FirstOrDefault();
                ddoc.documentname        = request.documentname;
                ddoc.documentdescription = request.documentdescription;
                ddoc.lastupdated         = DateTime.Now;
                ddoc.updatedby           = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId;
                db.SaveChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, DTOResponseError.NoError(), "application/json"));
            }
        }
 public HttpResponseMessage saveTaskstate(DTOtaskstatepool request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var dtsp = db.taskstatepool.Where(t => t.taskstateid == request.taskstateid).FirstOrDefault();
         dtsp.taskstate   = request.taskstate;
         dtsp.statetype   = request.statetype;
         dtsp.lastupdated = DateTime.Now;
         dtsp.updatedby   = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId;
         db.SaveChanges();
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Exemplo n.º 12
0
        public HttpResponseMessage insertCustomer(customer ct)
        {
            using (var db = new KOCSAMADLSEntities())
                using (var tran = db.Database.BeginTransaction())
                    try
                    {
                        var item = new customer();
                        item.customername      = ct.customername.ToUpper();
                        item.superonlineCustNo = ct.superonlineCustNo;
                        item.gsm             = ct.gsm;
                        item.tc              = ct.tc;
                        item.phone           = ct.phone;
                        item.birthdate       = ct.birthdate;
                        item.ilKimlikNo      = ct.ilKimlikNo;
                        item.ilceKimlikNo    = ct.ilceKimlikNo;
                        item.bucakKimlikNo   = ct.bucakKimlikNo;
                        item.mahalleKimlikNo = ct.mahalleKimlikNo;
                        item.yolKimlikNo     = 61;
                        item.binaKimlikNo    = 61;
                        item.daire           = 61;
                        item.creationdate    = DateTime.Now;
                        item.lastupdated     = DateTime.Now;
                        item.updatedby       = KOCAuthorizeAttribute.getCurrentUser().userId;
                        item.email           = ct.email;
                        item.deleted         = false;
                        item.description     = ct.description;
                        db.customer.Add(item);
                        db.SaveChanges();

                        tran.Commit();
                        var customer     = db.customer.First(r => r.tc == ct.tc);
                        var errormessage = new DTOResponseError {
                            errorCode = 1, errorMessage = "İşlem Tamamlandı."
                        };
                        return(Request.CreateResponse(HttpStatusCode.OK, new { errormessage, customer }, "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        var errormessage = new DTOResponseError {
                            errorCode = 2, errorMessage = "İşlem Tamamlanamadı!"
                        };
                        return(Request.CreateResponse(HttpStatusCode.NotModified, new { errormessage }, "application/json"));
                    }
        }
Exemplo n.º 13
0
        public HttpResponseMessage saveFiles()
        {
            try
            {
                var request = HttpContext.Current.Request;

                var    custid  = Convert.ToInt32(request.Form["img_key"].Split('-')[0]);
                var    il      = request.Form["il"].ToString();
                var    ilce    = request.Form["ilce"].ToString();
                var    tqid    = Convert.ToInt32(request.Form["tqid"]);
                var    userid  = Convert.ToInt32(request.Form["updatedby"]);
                var    docid   = Convert.ToInt32(request.Form["docid"]);
                string subPath = "E:\\CRMADSLWEB\\Files\\" + il + '\\' + ilce + '\\' + request.Form["img_key"] + "\\";
                System.IO.Directory.CreateDirectory(subPath);
                var filePath = subPath + ((request.Files["file_data"])).FileName;
                using (var fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
                {
                    (request.Files["file_data"]).InputStream.CopyTo(fs);
                }
                using (var db = new KOCSAMADLSEntities())
                {
                    var cdoc = new adsl_customerdocument
                    {
                        customerid         = custid,
                        attachedobjecttype = 3000,
                        taskqueueid        = tqid,
                        documentid         = docid,
                        documenturl        = filePath,
                        receiptdate        = DateTime.Now,
                        creationdate       = DateTime.Now,
                        lastupdated        = DateTime.Now,
                        updatedby          = userid,
                        deleted            = false
                    };
                    db.customerdocument.Add(cdoc);
                    db.SaveChanges();
                }
                var req = JsonConvert.DeserializeObject <DTOtaskqueue>(request.Form["tq"]);
                return(Request.CreateResponse(HttpStatusCode.OK, "uploaded", "application/json"));;
            }
            catch (Exception)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "error", "application/json"));;
            }
        }
Exemplo n.º 14
0
 public HttpResponseMessage insertPersonelAtama(DTOatama request)
 {
     using (var db = new KOCSAMADLSEntities())
         using (var tran = db.Database.BeginTransaction())
             try
             {
                 var errormessage = new DTOResponseError {
                     errorCode = 1, errorMessage = "İşlem Başarılı"
                 };
                 int arrayLenght;
                 if (request.formedtaskarray != null)
                 {
                     arrayLenght = request.formedtaskarray.Length;
                 }
                 else
                 {
                     arrayLenght = 1;
                 }
                 for (int i = 0; i < arrayLenght; i++)
                 {
                     var p = new atama
                     {
                         closedtasktype    = request.closedtasktype,
                         closedtask        = request.closedtask,
                         offpersonel       = request.offpersonel,
                         formedtasktype    = request.formedtasktype,
                         formedtask        = request.formedtaskarray != null ? request.formedtaskarray[i] : null,
                         appointedpersonel = request.appointedpersonel,
                     };
                     db.atama.Add(p);
                 }
                 db.SaveChanges();
                 tran.Commit();
                 return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
             }
             catch (Exception)
             {
                 tran.Rollback();
                 var errormessage = new DTOResponseError {
                     errorCode = 2, errorMessage = "Hata Oluştu"
                 };
                 return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
             }
 }
Exemplo n.º 15
0
        public HttpResponseMessage SaveStockMovement(adsl_stockmovement r, int?tqid, string serinos)
        {
            var userID = KOCAuthorizeAttribute.getCurrentUser().userId;

            if (r.movementid <= 0)
            {
                return(InsertStockMovement(r, tqid, serinos));
            }
            else
            {
                using (var db = new KOCSAMADLSEntities())
                {
                    var Records = db.stockmovement.Include(s => s.stockcard).Where(s => s.movementid == r.movementid);
                    if (Records.Count() > 0)
                    {
                        var Record = Records.First();

                        if (r.toobject == userID && r.confirmationdate != null && Record.confirmationdate == null)  //confirmationroles.Contains(r.toobjecttype) &&  if şartlarına eklenecek yetkilendirmeden sonra
                        {
                            Record.confirmationdate = DateTime.Now;
                        }
                        else
                        {
                            if (Record.stockcard.hasserial == true && string.IsNullOrWhiteSpace(r.serialno))
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, tqid, "application/json"));//seri numarası girilmesi gerekirken girilmemişse veya boşluk gibi bir karakter girilmişse
                            }
                            Record.amount           = string.IsNullOrWhiteSpace(r.serialno) ? r.amount : 1;
                            Record.relatedtaskqueue = r.relatedtaskqueue;
                            Record.serialno         = r.serialno;
                            Record.stockcardid      = r.stockcardid;
                            Record.toobject         = r.toobject;
                            Record.toobjecttype     = r.toobjecttype;
                        }
                        Record.updatedby   = userID;
                        Record.lastupdated = DateTime.Now;
                        db.SaveChanges();
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, tqid, "application/json"));
                }
            }
        }
Exemplo n.º 16
0
        public HttpResponseMessage saveCampaigns(DTOcampaigns request)
        {
            using (var db = new KOCSAMADLSEntities())
            {
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                var dcamp = db.campaigns.Where(t => t.id == request.id).FirstOrDefault();

                dcamp.name        = request.name;
                dcamp.category    = request.category;
                dcamp.subcategory = request.subcategory;
                dcamp.products    = request.products;
                dcamp.documents   = request.documents;
                dcamp.lastupdated = DateTime.Now;
                dcamp.updatedby   = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId;
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Exemplo n.º 17
0
        public HttpResponseMessage saveProduct(DTOProduct_service request)
        {
            using (var db = new KOCSAMADLSEntities())
            {
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                var dpro = db.product_service.Where(t => t.productid == request.productid).FirstOrDefault();

                dpro.productname        = request.productname;
                dpro.category           = request.category;
                dpro.maxduration        = request.maxduration;
                dpro.automandatorytasks = request.automandatorytasks;
                dpro.documents          = request.documents;
                dpro.lastupdated        = DateTime.Now;
                dpro.updatedby          = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId;
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
        public HttpResponseMessage saveStockCard(DTOstockcard request)
        {
            using (var db = new KOCSAMADLSEntities())
            {
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                var ds = db.stockcard.Where(t => t.stockid == request.stockid).FirstOrDefault();

                ds.productname = request.productname;
                ds.category    = request.category;
                ds.hasserial   = request.hasserial;
                ds.unit        = request.unit;
                ds.description = request.description;
                ds.lastupdated = DateTime.Now;
                ds.updatedby   = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId;
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Exemplo n.º 19
0
 public HttpResponseMessage saveTaskStateMatches(DTOtaskstatematches request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var dtsm = db.taskstatematches.Where(t => t.id == request.id).FirstOrDefault();
         dtsm.taskid             = request.task.taskid;
         dtsm.stateid            = request.taskstatepool.taskstateid;
         dtsm.automandatorytasks = request.automandatorytasks;
         dtsm.autooptionaltasks  = request.autooptionaltasks;
         dtsm.stockcards         = request.stockcards;
         dtsm.documents          = request.documents;
         dtsm.lastupdated        = DateTime.Now;
         dtsm.updatedby          = KOCAuthorizeAttribute.getCurrentUser().userId;
         db.SaveChanges();
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Exemplo n.º 20
0
        public HttpResponseMessage saveTask(DTOtask request)
        {
            using (var db = new KOCSAMADLSEntities())
            {
                var dt           = db.task.Where(t => t.taskid == request.taskid).FirstOrDefault();
                var errormessage = new DTOResponseError();

                dt.description            = request.description;
                dt.taskname               = request.taskname;
                dt.performancescore       = request.performancescore;
                dt.tasktype               = request.tasktypes.TaskTypeId;
                dt.attachableobjecttype   = request.objecttypes.typeid;
                dt.attachablepersoneltype = request.personeltypes.typeid;
                dt.updatedby              = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId;
                dt.lastupdated            = DateTime.Now;
                db.SaveChanges();
                errormessage.errorCode    = 1;
                errormessage.errorMessage = "İşlem Başarılı";
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
 public HttpResponseMessage insertTaskState(DTOtaskstatepool request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var tsp = new adsl_taskstatepool
         {
             taskstate    = request.taskstate,
             statetype    = request.statetype,
             creationdate = DateTime.Now,
             lastupdated  = DateTime.Now,
             updatedby    = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId,
             deleted      = false
         };
         db.taskstatepool.Add(tsp);
         db.SaveChanges();
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Exemplo n.º 22
0
 public HttpResponseMessage insertDocument(DTOdocument request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var d = new adsl_document
         {
             documentname        = request.documentname,
             documentdescription = request.documentdescription,
             creationdate        = DateTime.Now,
             lastupdated         = DateTime.Now,
             deleted             = false,
             updatedby           = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId
         };
         db.document.Add(d);
         db.SaveChanges();
         DTOResponseError errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Exemplo n.º 23
0
 public HttpResponseMessage saveCustomerCard(DTOcustomer ct)
 {
     using (var db = new KOCSAMADLSEntities())
         using (var transaction = db.Database.BeginTransaction())
             try
             {
                 var oldCust = db.customer.Where(c => c.tc == ct.tc && c.deleted == false).ToList();
                 if (oldCust.Count == 0 || oldCust.Where(r => r.customerid == ct.customerid).FirstOrDefault() != null)
                 {
                     if (db.customer.Any(c => c.customerid == ct.customerid))
                     {
                         var item = db.customer.Where(c => c.customerid == ct.customerid).First();
                         item.customername      = ct.customername;
                         item.gsm               = ct.gsm;
                         item.tc                = ct.tc;
                         item.ilKimlikNo        = ct.ilKimlikNo;
                         item.ilceKimlikNo      = ct.ilceKimlikNo;
                         item.bucakKimlikNo     = ct.bucakKimlikNo;
                         item.mahalleKimlikNo   = ct.mahalleKimlikNo;
                         item.phone             = ct.phone;
                         item.birthdate         = ct.birthdate;
                         item.lastupdated       = DateTime.Now;
                         item.updatedby         = KOCAuthorizeAttribute.getCurrentUser().userId;
                         item.email             = ct.email;
                         item.superonlineCustNo = ct.superonlineCustNo;
                         item.xdslno            = ct.xdslno;
                         item.description       = ct.description;
                     }
                     db.SaveChanges();
                     transaction.Commit();
                     return(Request.CreateResponse(HttpStatusCode.OK, "ok", "application/json"));
                 }
                 return(Request.CreateResponse(HttpStatusCode.OK, "Girilen TC Numarası Başkasına Aittir", "application/json"));
             }
             catch
             {
                 transaction.Rollback();
                 return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, "error", "application/json"));
             }
 }
Exemplo n.º 24
0
        public HttpResponseMessage insertSL(DTOSL request)
        { // SL hesaplamaları için gerekli olan bilgilerin kaydı (Hüseyin KOZ)
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new KOCSAMADLSEntities())
                using (var tran = db.Database.BeginTransaction())
                    try
                    {
                        var errormessage = new DTOResponseError {
                            errorCode = 1, errorMessage = "İşlem Başarılı"
                        };
                        var p = new SL
                        {
                            SLName      = request.SLName,
                            KocSTask    = request.KocSTask,
                            KocETask    = request.KocETask,
                            KocMaxTime  = request.KocMaxTime,
                            BayiSTask   = request.BayiSTask,
                            BayiETask   = request.BayiETask,
                            BayiMaxTime = request.BayiMaxTime,
                            lastupdated = DateTime.Now,
                            updatedby   = user.userId,
                            deleted     = false,
                        };
                        db.SL.Add(p);
                        db.SaveChanges();
                        tran.Commit();
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        var errormessage = new DTOResponseError {
                            errorCode = 2, errorMessage = "Hata Oluştu"
                        };
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
        }
Exemplo n.º 25
0
 public HttpResponseMessage deletePersonelAtama(int id)
 {
     using (var db = new KOCSAMADLSEntities())
         using (var tran = db.Database.BeginTransaction())
             try
             {
                 var upa = db.atama.Where(r => r.id == id).FirstOrDefault();
                 //delete
                 db.SaveChanges();
                 tran.Commit();
                 var errormessage = new DTOResponseError {
                     errorCode = 1, errorMessage = "işlem Gerçekleştirildi."
                 };
                 return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
             }
             catch (Exception)
             {
                 tran.Rollback();
                 var errormessage = new DTOResponseError {
                     errorCode = 2, errorMessage = "işlem Tamamlanamadı!"
                 };
                 return(Request.CreateResponse(HttpStatusCode.NotModified, errormessage, "application/json"));
             }
 }
Exemplo n.º 26
0
 public HttpResponseMessage insertProduct(DTOProduct_service request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         var p = new adsl_product_service
         {
             productname        = request.productname,
             category           = request.category,
             automandatorytasks = request.automandatorytasks,
             maxduration        = request.maxduration,
             documents          = request.documents,
             creationdate       = DateTime.Now,
             lastupdated        = DateTime.Now,
             deleted            = false,
             updatedby          = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId,
         };
         db.product_service.Add(p);
         db.SaveChanges();
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
 public HttpResponseMessage insertStockCard(DTOstockcard request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         var s = new adsl_stockcard
         {
             productname  = request.productname,
             category     = request.category,
             hasserial    = request.hasserial,
             unit         = request.unit,
             description  = request.description,
             creationdate = DateTime.Now,
             lastupdated  = DateTime.Now,
             deleted      = false,
             updatedby    = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId
         };
         db.stockcard.Add(s);
         db.SaveChanges();
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Exemplo n.º 28
0
 public HttpResponseMessage insertCampaigns(DTOcampaigns request)
 {
     using (var db = new KOCSAMADLSEntities())
     {
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         var c = new adsl_campaigns
         {
             name         = request.name,
             category     = request.category,
             subcategory  = request.subcategory,
             products     = request.products,
             documents    = request.documents,
             creationdate = DateTime.Now,
             lastupdated  = DateTime.Now,
             deleted      = false,
             updatedby    = KOCAuthorization.KOCAuthorizeAttribute.getCurrentUser().userId
         };
         db.campaigns.Add(c);
         db.SaveChanges();
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Exemplo n.º 29
0
        public HttpResponseMessage InsertStockMovement(adsl_stockmovement r, int?tqid, string serinos)
        {
            //  var serinos = Request.Params.AllKeys;
            HashSet <int> perids = new HashSet <int>()
            {
                4672, 4673
            };
            var serials      = serinos.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
            var errormessage = new DTOResponseError();

            if (!serials.Any())
            {
                serials.Add(null);
            }
            if (ModelState.IsValid)
            {
                var userID   = KOCAuthorizeAttribute.getCurrentUser().userId;//depocu
                var userType = KOCAuthorizeAttribute.getCurrentUser().userRole;
                using (var db = new KOCSAMADLSEntities())
                {
                    foreach (var seri in serials)
                    {
                        //serino kontrolü yap. varsa ekleme.
                        var userControl = db.stockmovement.Where(s => s.serialno == seri && s.deleted == false).OrderByDescending(s => s.movementid).Select(s => s.toobject).FirstOrDefault();
                        if (seri != null && (userControl != userID) && ((r.toobjecttype & (int)KOCUserTypes.StockRoomStuff) != (int)KOCUserTypes.StockRoomStuff))//satınalmadan depoya çıkış için özel durum
                        {
                            errormessage.errorCode    = -1;
                            errormessage.errorMessage = "Yalnızca Kendinize Ait Ürünleri Başkasına Çıkabilirsiniz";
                        }

                        #region hareket uygunsa
                        else
                        {
                            var count = db.stockmovement.Where(s => s.serialno == seri).Count();
                            //satınalmadan depoya ürün girerken seri numarası kontrolü yap
                            if (r.fromobjecttype == 33554433 && (r.toobjecttype & (int)KOCUserTypes.StockRoomStuff) == (int)KOCUserTypes.StockRoomStuff && (int)count > 0)
                            {
                                errormessage.errorCode    = -1;
                                errormessage.errorMessage = seri + " Seri numarası daha önce girilmiş! Lütfen Kontrol Ediniz!";
                            }
                            else
                            {
                                var stm = db.stockmovement.Where(s => s.serialno == seri && s.deleted == false && s.confirmationdate == null).ToList();
                                stm.ForEach(s =>
                                {
                                    s.updatedby   = userID;
                                    s.lastupdated = DateTime.Now;
                                    s.deleted     = true;
                                }); // bir seri onaylanmadan başka birisine çıkıldığında onaylanmayan hareketi sil (Hüseyin KOZ) 27.10.2016

                                adsl_stockmovement sm = new adsl_stockmovement();
                                sm.serialno         = seri;
                                sm.lastupdated      = DateTime.Now;
                                sm.creationdate     = DateTime.Now;
                                sm.toobjecttype     = r.toobjecttype;
                                sm.stockcardid      = r.stockcardid;
                                sm.toobject         = r.toobject;
                                sm.deleted          = false;
                                sm.amount           = seri == null ? r.amount : 1;
                                sm.relatedtaskqueue = tqid;
                                if (KOCAuthorizeAttribute.getCurrentUser().userRole == (int)KOCUserTypes.StockRoomStuff) // (long)KocCRMRoles.kscrStockStaff
                                {
                                    if (r.toobjecttype == (int)KOCUserTypes.StockRoomStuff)                              // ise bu bir satınalma işlemidir.
                                    {
                                        sm.fromobjecttype   = (int)KOCUserTypes.ADSLProcurementAssosiation;
                                        sm.fromobject       = (int)KOCUserTypes.ADSLProcurementAssosiation;
                                        sm.confirmationdate = DateTime.Now;
                                    }
                                    else
                                    {
                                        sm.fromobjecttype = (int)KOCUserTypes.StockRoomStuff;
                                        sm.fromobject     = KOCAuthorizeAttribute.getCurrentUser().userId;
                                    }
                                }
                                else
                                {
                                    sm.fromobjecttype = userType;// Convert.ToInt32(User.Identity.TitleCode);
                                    sm.fromobject     = userID;
                                }
                                if (r.relatedtaskqueue != null)
                                {
                                    sm.confirmationdate = DateTime.Now;
                                }
                                if (perids.Contains(r.toobject.Value))
                                {
                                    sm.confirmationdate = DateTime.Now;                                    // listedeki personellere modem atıldığında işlem otomatik onaylanacak (28.04.2017) Hüseyin KOZ
                                }
                                sm.movementdate = DateTime.Now;
                                sm.updatedby    = userID;
                                db.stockmovement.Add(sm);
                                db.SaveChanges();
                            }
                        }
                        #endregion
                    }
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK, tqid, "application/json"));
        }
Exemplo n.º 30
0
        public async Task <HttpResponseMessage> getAdress(DTOGetAdressFilter request)
        {
            using (var db = new KOCSAMADLSEntities())
            {
                //var il = TeknarProxyService.DeserializeJSON<il>();
                var filter   = request.getFilter();
                var querySql = filter.getFilterSQL();
                if (filter.tableName == "ilce")
                {
                    var res = db.ilce.SqlQuery(querySql).ToList();
                    if (res.Count < 2)
                    {
                        var ilData = $"lnaj1hV9YSL2LjqEADiS9aLNc2015111912awiAQeCo723cW7/IyM3kk045ditq+ESdsbTdVfgMbN5Anwk3lx6H/cc9QTTadbSJA==&t=ce&u={request.adres.value}";
                        var url    = "http://adreskodu.dask.gov.tr/site-element/control/load.ashx";
                        try
                        {
                            var dres = (await TeknarProxyService.DeserializeJSON <daskResponseJSON>(url, ilData));
                            db.ilce.AddRange(dres.Result.yt.Skip(1).Where(s => !(new int[] { 2097 }).Contains(s.value.Value)).Select(s => new ilce
                            {
                                ad         = s.text,
                                ilKimlikNo = Convert.ToInt32(request.adres.value),
                                kimlikNo   = s.value.Value
                            }));
                            db.SaveChanges();
                        }
                        catch (Exception)
                        {
                            throw;
                        }

                        res = db.ilce.SqlQuery(querySql).ToList();
                    }
                    var t = res.Select(s => s.toDTO()).ToList();
                    return(Request.CreateResponse(HttpStatusCode.OK, t, "application/json"));
                }
                else if (filter.tableName == "bucak")
                {
                    var res = db.bucak.SqlQuery(querySql).ToList();
                    if (res.Count < 1)
                    {
                        var bucakData = $"lnaj1hV9YSL2LjqEADiS9aLNc2015111912awiAQeCo723cW7/IyM3kk045ditq+ESdsbTdVfgMbN5Anwk3lx6H/cc9QTTadbSJA==&t=vl&u={request.adres.value}";
                        var url       = "http://adreskodu.dask.gov.tr/site-element/control/load.ashx";
                        int error     = 1;
                        while (error == 1)
                        {
                            try
                            {
                                var dres = (await TeknarProxyService.DeserializeJSON <daskResponseJSON>(url, bucakData));
                                db.bucak.AddRange(dres.Result.yt.Skip(1).Where(s => !(new int[] { 0 }).Contains(s.value.Value)).Select(s => new bucak
                                {
                                    ad           = s.text,
                                    ilceKimlikNo = Convert.ToInt32(request.adres.value),
                                    kimlikNo     = s.value.Value
                                }));
                                db.SaveChanges();
                                error = 0;
                            }
                            catch (Exception)
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, "-1", "application/json"));
                            }
                        }


                        res = db.bucak.SqlQuery(querySql).ToList();
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, res.Select(s => s.toDTO()).ToList(), "application/json"));
                }
                else if (filter.tableName == "mahalleKoy")
                {
                    var res = db.mahalleKoy.SqlQuery(querySql).ToList();
                    if (res.Count < 1)
                    {
                        var bucakData = $"lnaj1hV9YSL2LjqEADiS9aLNc2015111912awiAQeCo723cW7/IyM3kk045ditq+ESdsbTdVfgMbN5Anwk3lx6H/cc9QTTadbSJA==&t=mh&u={request.adres.value}";
                        var url       = "http://adreskodu.dask.gov.tr/site-element/control/load.ashx";
                        int error     = 1;
                        while (error == 1)
                        {
                            try
                            {
                                var dres = (await TeknarProxyService.DeserializeJSON <daskResponseJSON>(url, bucakData));
                                db.mahalleKoy.AddRange(dres.Result.yt.Skip(1).Where(s => !(new int[] { 0 }).Contains(s.value.Value)).Select(s => new mahalleKoy
                                {
                                    ad            = s.text,
                                    bucakKimlikNo = Convert.ToInt32(request.adres.value),
                                    kimlikNo      = s.value.Value
                                }));
                                db.SaveChanges();
                                error = 0;
                            }
                            catch (Exception)
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, "-1", "application/json"));
                            }
                        }
                        res = db.mahalleKoy.SqlQuery(querySql).ToList();
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, res.Select(s => s.toDTO()).ToList(), "application/json"));
                }
                else if (filter.tableName == "cadde")
                {
                    var res = db.cadde.SqlQuery(querySql).ToList();
                    return(Request.CreateResponse(HttpStatusCode.OK, res.ToList(), "application/json"));
                }
                else if (filter.tableName == "bina")
                {
                    var res = db.bina.SqlQuery(querySql).ToList();
                    return(Request.CreateResponse(HttpStatusCode.OK, res.ToList(), "application/json"));
                }
                else if (filter.tableName == "daire")
                {
                    var res = db.daire.SqlQuery(querySql).ToList();
                    return(Request.CreateResponse(HttpStatusCode.OK, res.ToList(), "application/json"));
                }
                else
                {
                    var res = db.il.SqlQuery(querySql).ToList();
                    if (res.Count == 0)
                    {
                        var ilData = "xMf1xgor4FG+LM9PJdCPruS0m2015111822y3yj7YxRo232eFmoz/WNhy11S9YjcSvl8NMI1rT2WwjdmPRLtK6lxgOEhjoQr+ezQ==&t=il&u=0";
                        var url    = "http://adreskodu.dask.gov.tr/site-element/control/load.ashx";
                        db.il.AddRange((await TeknarProxyService.DeserializeJSON <daskResponseJSON>(url, ilData)).Result.yt.Skip(1).Where(s => !(new int[] { 34, 61 }).Contains(s.value.Value)).Select(s => new il
                        {
                            ad       = s.text,
                            kimlikNo = s.value.Value
                        }));
                        try
                        {
                            db.SaveChanges();
                        }
                        catch (Exception)
                        {
                            throw;
                        }

                        res = db.il.SqlQuery(querySql).ToList();
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, res.Select(s => s.toDTO()).ToList(), "application/json"));
                }
            }
        }